I have the following table user_user with fields (userid1, userid2)
I want to select all users that are related to a specific user X, whether or not they are in the first or second column. But I only want to select the other users…i.e. I don’t want X to be part of the result set.
How does one do this?
SELECT * FROM user_user WHERE userid1 = X.id OR userid2=X.id will give pretty much a sub-table that is not a straight forward list of users in relationship with X and needs some post processing…is there a more direct SQL command?
1 Answer