我有一个需要受用户限制的表,我想到了两种实现仅显示用户特定视图的查询的方法。一种方法是让我将每个条目交叉连接到当前用户,第二种方法是将用户名查询作为where子句中的子查询。我想知道哪个性能效果最好,或者无所谓?
CROSS JOIN:
SELECT quota.username, quota.quota
FROM quota
CROSS JOIN
(SELECT nt_username AS [username]
FROM sys.sysprocesses
WHERE spid = @@SPID) o
WHERE quota.username = o.[username]
OR
SELECT quota.username, quota.quota
FROM quota
WHERE
quota.username =
(SELECT nt_username
FROM sys.sysprocesses
WHERE spid = @@SPID)
感谢您的帮助和指导!