我正在尝试从3个表中提取数据,这是我正在使用的代码。但是它没有给出错误消息,它只返回空行。我正在使用SQL Server Mgmt Studio
select l.user_name, l.display_name, m.group_name, m.GROUP_ID
from dbo.groups m, dbo.group_members n, dbo.users l
where l.user_id = n.member_group_id
and n.group_id = m.group_id
答案 0 :(得分:0)
您缺少内部联接声明。
select l.user_name, l.display_name, m.group_name, m.GROUP_ID
from dbo.groups m
inner join dbo.group_members n on n.primarykey = m.foreignkey
inner join dbo.users l on on l.primarykey = m.foreignkey
where l.user_id = n.member_group_id
and n.group_id = m.group_id
答案 1 :(得分:0)
戈迪的解决方案有效......再次谢谢
//
将l.user_id = n.member_group_id更改为l.user_id = n.member_user_id