3
我会尝试解释我所面临的问题。两个表的SQL查询
我有两个表:团队和Team_contacts
在第一个表不存在像信息: MEMBER_NAME,member_picture,电话和电子邮件
在team_contacts表,只有国家和城市部件负责。
所以第一个表看起来像这样:
member_id: 1
member_name: moonwalker
member_picture: mw.jpg
member_phone: 06xxxxxxxx
member_email: [email protected]
第二个表是这样的:
member_id: 1
country: USA
city: California
member_id: 1
country: USA
city: Miami
member_id: 1
country: NL
city: Amsterdam
我需要的是显示了下列查询:
mw.jpg
Moonwalker
Phone: 06xxxxxxxx
Email: [email protected]
Active in countries: USA, NL
Active in cities: California, Miami, Amsterdam
我尝试了不同的连接方法,但似乎没有任何工作。有没有办法做到这一点与单个查询或我需要使用两个不同的查询?如何?
非常感谢您的帮助。
非常感谢。这似乎工作。只剩下一个小问题:现在国家重复了。所以我多次看到同一个国家。有没有办法只显示一次?再次感谢! – moonwalker
没关系。在桌上使用DISTINCT。非常感谢AndreKR。 :) – moonwalker