我有3个表如下SQL查询,以避免环或游标读取记录
Table #1 has column UserId and UserName
Table #2 has column MenuId and MenuName
Table #3 has column MappingId, UserId, MenuId
(在表#3列的用户ID和MENUID分别具有表#1用户id和表#2 MENUID外键关系。)
我想选择语句,如果用户名和MENUNAME组合表#3已经存在,否则它会像假
UserName, MenuName, AllowedDisallowedFlag
Where
UserName is Names of User From Table #1
MenuName is Names of Menu from Table #2
和AllowedDisallowedFlag
将是真实的。
有什么办法可以在不使用游标或循环的情况下实现这一点吗?
是的,正常的SQL方法是使用[joins](http://en.wikipedia.org/wiki/Join_(SQL))。 – Oded
@oded你可以帮我查询吗?我的意思是如何使用连接实现这个? –