我有这个查询,它从结果中给了我以前的 id,但它包含多个where
子句。
SELECT DISTINCT Contacts.cm_id
FROM Contacts
LEFT JOIN Employee ON (Contacts.cm_id = Employee.ei_contact_id) AND (Employee.ei_primary_employer = "Y")
WHERE ( CONCAT( Contacts.cm_fname," ", Contacts.cm_lname ) LIKE '%Recee Dawn%'
AND CONCAT( Contacts.cm_fname," ", Contacts.cm_lname ) NOT LIKE 'NULL' )
WHERE Contacts.cm_id < (
SELECT DISTINCT Contacts.cm_id
FROM Contacts
LEFT JOIN Employee ON (Contacts.cm_id = Employee.ei_contact_id) AND (Employee.ei_primary_employer = "Y")
WHERE ( CONCAT( Contacts.cm_fname," ", Contacts.cm_lname ) LIKE '%Recee Dawn%' AND CONCAT( Contacts.cm_fname," ", Contacts.cm_lname ) NOT LIKE 'NULL' )
WHERE Contacts.cm_id='77')
ORDER BY Contacts.cm_id DESC LIMIT 1
它给了我这个error
'WHERE Contacts.cm_id='313')) ORDER BY Contact_Master.cm_id DESC LIMIT 1' at line 10
如何调整此查询以避免查询中断。请帮忙