I am trying to make an application that will display every other user that is not the logged in user or that the logged in user does not not follow (like an explore page), but I'm having trouble writing the SQL query.
My tables are set up as:
following(username1, username2)
(meaning username1 follows username2)
and
users(username, fullname, ...)
Right now I am trying to do something like:
SELECT * FROM
users u
LEFT JOIN following f ON (
u.username != 'loggedInUser'
AND f.username1 = 'loggedInUser'
AND f.username2 = u.username
)
I replace loggedInUser in a Python script.
Unfortunately, this query is currently returning all of my users, and it should not be. I'm having a lot of issues working though this logic for some reason, does anyone have some insight?