Exclude Statement in SQL

Maybe just

SELECT *
FROM 
    Users
WHERE
    UserId <> @ThisUserId

Or using a Difference Union (The EXCEPT keyword in SQL Server, not sure about other RDBMS implementations)

SELECT *
FROM 
    Users

EXCEPT

SELECT *
FROM 
    Users
WHERE
    UserId = @ThisUserId

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)