简体   繁体   English

交叉引用表列

[英]cross referencing table columns

I am trying to select the names from one table column and then ignore if any rows have the same member as the user id in a different column.我试图从一个表列中选择名称,然后忽略是否有任何行与不同列中的用户 ID 具有相同的成员。

for example i would like to select all the "groupNames" from groups then check the "members" column for any members that match the user.例如,我想从组中选择所有“groupNames”,然后检查与用户匹配的任何成员的“成员”列。

members    groupName
mike       test
andy       test
eric       runners
erica      test

If the user was "mike", I would like the list to ignore any row that had the "groupName" test as "mike" also has that as a group name and the list should only display runners.如果用户是“mike”,我希望列表忽略具有“groupName”测试的任何行,因为“mike”也将其作为组名,并且列表应该只显示跑步者。

Is this possible?这可能吗? I have tried to research it but not even sure what I need to search for?我试图研究它,但甚至不确定我需要搜索什么?

Does this do what you want?这是你想要的吗?

select t.*
from groups t
where t.groupName <> (select t2.groupName from groups t2 where t2.members = 'Mike');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM