我想显示所有来自 Users
表,谁的 id
存在于表中 favorite_group_users
作为 user_id
对于 favorite_groups.id = favorite_group_users.id
.
我使用了下面的查询,但它返回null。
select users.id as user_id, users.first_name as name,
favorite_groups.id as group_id,
favorite_groups_users.user_id as carrier_id
from users
inner join favorite_groups
on users.id = favorite_groups.user_id
inner join favorite_groups_users
on favorite_groups.id = favorite_groups_users.favorite_group_id
where users.id = 38;
1条答案
按热度按时间mum43rcc1#
您可以尝试嵌套选择