I have a very critical code. I'm trying to select all records from two columns of one table that matches the records of another table in one column. here's a my result so far
SELECT username FROM users
WHERE username NOT IN (SELECT friend FROM friends WHERE friend = 'user1')
AND username NOT IN (SELECT you FROM friends WHERE you = 'user1')
This can't be right... I want the records in column [username] that doesn't match 'user1' in both columns [you] and [friend] in table {friends} to be a result of that sql selection. please see the demo for more understanding. thanks for your help.
Problem solved, hopefully this can help other people
SELECT username,you,friend FROM users, friends
WHERE you IN (SELECT you FROM friends WHERE you != 'user1')
AND friend IN (SELECT friend FROM friends WHERE friend != 'user1')
AND username IN (you,friend)
and this is a Live demo