php - How can I adjust multiple 'where' clause in single query? -


i have query gives me previous id result contains multiple where clause .

select distinct contacts.cm_id      contacts      left join employee on (contacts.cm_id = employee.ei_contact_id) , (employee.ei_primary_employer = "y")   ( concat( contacts.cm_fname," ", contacts.cm_lname ) '%recee dawn%'      , concat( contacts.cm_fname," ", contacts.cm_lname ) not 'null' )   contacts.cm_id < (     select distinct contacts.cm_id          contacts          left join employee on (contacts.cm_id = employee.ei_contact_id) , (employee.ei_primary_employer = "y")          ( concat( contacts.cm_fname," ", contacts.cm_lname ) '%recee dawn%' , concat( contacts.cm_fname," ", contacts.cm_lname ) not 'null' )          contacts.cm_id='77')  order contacts.cm_id desc limit 1 

its giving me error

'where contacts.cm_id='313')) order contact_master.cm_id desc limit 1' @ line 10 

how can adjust query avoid query break. please help

your query syntax ist wrong, and after left join ... on ... should inside where caluse, , combine where caluses and instead of where each time, have 1 where each select.

try this:

select distinct contacts.cm_id  contacts left join employee       on (contacts.cm_id = employee.ei_contact_id)  (employee.ei_primary_employer = "y")    , ( concat( contacts.cm_fname," ", contacts.cm_lname ) '%recee dawn%'    , concat( contacts.cm_fname," ", contacts.cm_lname ) not 'null' )    , contacts.cm_id <       (select distinct contacts.cm_id        contacts left join employee             on (contacts.cm_id = employee.ei_contact_id)         (employee.ei_primary_employer = "y")          , (concat( contacts.cm_fname," ", contacts.cm_lname ) '%recee dawn%'          , concat( contacts.cm_fname," ", contacts.cm_lname ) not 'null' )          , contacts.cm_id='77') order contacts.cm_id desc limit 1) 

Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -