[英]Many-to-Many mySQL selection
如何获得显示特定用户所有兴趣的选择结果。 我的3个表格如下所示:
表格:用户
- ID
- 名字
- 姓
-等等...
Tabel:兴趣
- ID
-标题
表格:User_Interests
- 用户身份
-Interests_ID
这是我到目前为止所得到的:
SELECT
User.ID, User.first_name
FROM
User
INNER JOIN
User_Interests ON User_Interests.User_ID = User.ID
WHERE
User.ID = 0
enter code here
您还需要加入Interests
表
尝试这个:
SELECT
User.ID, User.first_name, Interests.title
FROM User
INNER JOIN User_Interests
ON User_Interests.User_ID = User.ID
INNER JOIN Interests
ON User_Interests.Interests_ID = Interests.ID
WHERE
User.ID = 0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.