I have an SQL table and I need to select all the records where username (MM_Session) is in another users following list (Users SQL table, following column), which would look like this
username1 username2 username3 username4
So far, my SQL query looks like this:
WHERE Users.Following_By LIKE '" . $_SESSION['MM_Username'] . "'
LIKE operator works just the same as
= if you don't use wildcard characters in your query string. Place them before and behind the word to match any occurrence of the word:
SELECT * FROM Users WHERE Users.Following_By LIKE '%" . $_SESSION['MM_Username'] . "%'
Though you might get more users than you expected because it matches for example
MM_USERname contains only
foo. You could use explicit delimiters to prevent this. Or, even better, use a separate table for the list entries and use a foreign key to join it to the