I am trying to add a second where clause/condition to a query and in doing so I am getting this error: Parse error: syntax error, unexpected ‘=’
This was working fine when the last line of the below code simply read: WHERE stories.SID = $the_SID");
But I need to add more conditions. Probably will need about 3 where clauses once I can figure out how to do 2 properly.
Here is the current code that is problematic on the last line:
$results = $wpdb->get_results("
SELECT wp_users.ID, wp_users.display_name,
stories.SID, stories.story_name, stories.category,
writing.text, writing.approved
FROM stories
INNER JOIN wp_users ON stories.ID = wp_users.ID
INNER JOIN writing ON stories.SID = writing.SID
WHERE (stories.SID = $the_SID") AND (writing.approved = "Y"));
Also....this query will return one record I think. There will be many records with the same SID however, I wan to display all of them that are approved. The approved variable is the only unique identifier. This should work with the above approach correct?