realjumper Posted January 17, 2008 Share Posted January 17, 2008 $result = mysql_query("SELECT e.email, e.sid, t.first_name, t.last_name, t.full_name, u.prefix, u.status FROM email e INNER JOIN true_name t ON e.sid = t.sid INNER JOIN users u ON e.sid = u.sid WHERE t.first_name LIKE '%$find%' OR t.last_name LIKE '%$find%' OR t.sid LIKE '%$find%' OR t.full_name LIKE '%$find%' OR e.email LIKE '%$find%' AND u.prefix != 's' AND u.status = 'Active'") or die(mysql_error()); The query runs just fine...except the 2 final 'AND' conditions are being ignored. The results returned include results which are entered in the DB with a 's' prefix and results which are entered in the DB as 'Inactive'. What's wrong with my 'AND' conditions? Thank you :-) Link to comment https://forums.phpfreaks.com/topic/86416-solved-whats-wrong-with-this-query-please/ Share on other sites More sharing options...
realjumper Posted January 17, 2008 Author Share Posted January 17, 2008 Got it :-))))) $result = mysql_query("SELECT e.email, e.sid, t.first_name, t.last_name, t.full_name, u.prefix, u.status FROM email e INNER JOIN true_name t ON e.sid = t.sid INNER JOIN users u ON e.sid = u.sid WHERE (t.first_name LIKE '%$find%' <--- see the bracket OR t.last_name LIKE '%$find%' OR t.sid LIKE '%$find%' OR t.full_name LIKE '%$find%' OR e.email LIKE '%$find%') <---- and the closing bracket AND u.prefix != 's' AND u.status = 'Active'") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/86416-solved-whats-wrong-with-this-query-please/#findComment-441612 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.