我有一个表格,我用ids存储用户。如何获得所有用户,除了我的?我想我需要这样的东西:
SELECT *
FROM USERS
EXCEPT WHERE iduser = myiduser
答案 0 :(得分:17)
SELECT * FROM USERS WHERE iduser != myiduser ;
或者这个:
SELECT * FROM USERS
except
select * from users
WHERE iduser = myiduser ;
或者您可以创建视图
Create View Everyone_else
as
SELECT * FROM USERS WHERE iduser != myiduser ;
然后用
调用它Select * from Everyone_else ;
您可能必须为myiduser使用撇号,如下所示:'myiduser'