I'm having trouble with a specific query (PDO style) that selects 4 fields from a table with a simple condition : contact_type='a' , label_id = a value (number) and also it checks that the particular contact type ('a') is not blocked, meaning is not in myl_blocked_contacts table. I LEFT
$query = "SELECT myl_contacts.contact_id, mya_users.name, mya_users.city, mya_users.ext
from myl_contacts, mya_users,
LEFT JOIN myl_blocked_contacts
WHERE myl_contacts.contact_type='a'
AND myl_contacts.label_id=:id
AND (myl_blocked_contacts.contact_type!='a'
AND myl_blocked_contacts.contact_id!=mya_users.id)
";
$result = $db->prepare($query);
$result->bindValue(':id', $_id, PDO::PARAM_INT);
$result->execute();
myl_contactsandmya_users– ypercube Oct 8 '12 at 14:05