SELECT * FROM USERS but not me

  • A+
Category:Languages

I have a table where I store users with ids. How to get all the users, except mine? I guess I'll need something like:

SELECT *  FROM USERS  EXCEPT WHERE iduser = myiduser 

 


SELECT * FROM USERS WHERE iduser != myiduser ; 

or this:

    SELECT * FROM USERS      except     select * from users     WHERE iduser = myiduser ; 

or you can create a view

Create View Everyone_else as SELECT * FROM USERS WHERE iduser != myiduser ; 

then call it with

Select * from Everyone_else ; 

you might have to use apostrophes for myiduser, like this: 'myiduser'

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: