如何在外键表中选择使用的记录 [英] how to select used record in foreign key table
本文介绍了如何在外键表中选择使用的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两张桌子,
艺术家
A_id A_name
1名称1
2名称2
3名称3
歌
s_id AID s_name
1 1名称
2 1名称
3 3名称
我的问题是怎样才能我从艺术家表中选择艺术家姓名,只使用歌曲表。我需要得到这样的结果
A_id A_nam
1名称1
3名称3 >
请帮助我.. !!
I have two tables,
artist
A_id A_name
1 name 1
2 name 2
3 name 3
song
s_id AID s_name
1 1 name
2 1 name
3 3 name
my problem is how can i select artist names from artist table only used song table. I need to get result like this
A_id A_nam
1 name 1
3 name 3
Please help me..!!
推荐答案
根据您的问题,答案是:
As per your question the answer is :
select distinct A.A_id,A.A_name from Artist A join Songs B on A.A_id=B.Aid
输出:
A_id A_name
1名称1
3姓名3
output :
A_id A_name
1 Name 1
3 Name 3
这篇关于如何在外键表中选择使用的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文