List all mysql records in a master table and last record in a related child table I want to list all records in a MySQL master table and the last record in the child table that is related to the master. Here is my code

$strsql="SELECT contact.id, contact.title, contact.init, contact.first_name, contact.last_name, contact.city, contact.home_phone, contact.mobile_phone, contact.e_mail,  status.status AS status, fundsource.fundsource AS fundsource, category.category AS category,contact.score, ROUND(value/1000000,1) AS value_M, jstate.jstate AS to_do, journal.l_date AS last_activity, journal.note AS journal FROM contact

LEFT JOIN journal ON journal.con_id=contact.id 
LEFT JOIN jstate ON jstate.jstate_code=journal.jstate_code
LEFT JOIN category ON category.cat_code=contact.cat_code
LEFT JOIN status ON status.st_code=contact.st_code
LEFT JOIN fundsource ON fundsource.fundsource_code=contact.fundsource_code 

WHERE journal.l_date=(SELECT MAX(journal.l_date) from journal WHERE journal.con_id = contact.id) GROUP BY contact.id " ;


But it outputs only related records which matching the PK and FK. Not displays all records in the master. Can any one help me?
Your WHERE-condition is reducing the output. If you need all the records from the contact table, please try something like this:

$strsql="SELECT contact.id, contact.title, contact.init, contact.first_name, contact.last_name, contact.city, contact.home_phone, contact.mobile_phone, contact.e_mail,  status.status AS status, fundsource.fundsource AS fundsource, category.category AS category,contact.score, ROUND(value/1000000,1) AS value_M, jstate.jstate AS to_do, journal.l_date AS last_activity, journal.note AS journal FROM contact

LEFT JOIN journal ON journal.con_id=contact.id AND journal.l_date=(SELECT MAX(journal.l_date) from journal WHERE journal.con_id = contact.id)
LEFT JOIN jstate ON jstate.jstate_code=journal.jstate_code
LEFT JOIN category ON category.cat_code=contact.cat_code
LEFT JOIN status ON status.st_code=contact.st_code
LEFT JOIN fundsource ON fundsource.fundsource_code=contact.fundsource_code 

WHERE contact.scode=$user-&gt;scode and contact.dcode=$user-&gt;dcode AND contact.st_code !=17 AND contact.st_code !=18
GROUP BY contact.id " ;