Jump to content

[SOLVED] What's wrong with this query please


realjumper

Recommended Posts


$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 :-)

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());

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.