Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.