Jump to content

Please help with query


leetee

Recommended Posts

I have the below query which pulls out what I want with one expection and I would be grateful if anyone can suggest how to solve it.

 

The joblist is the main table which links to the events table.  A job_id can be entered into the events table many times.  I need to pull out all job ids that are entered into the events list but only pull out each distinct job which was the most recent entry (according to the date).  At the moment, the query is pulling out the earliest job_id entered into the events table.

 

SELECT j.id,j.jobref,DATE_FORMAT(e.date, '%m/%Y') AS date FROM joblist as j
INNER JOIN events as e ON j.id=e.job_id
WHERE e.status_id = '9'
GROUP BY j.jobref
ORDER by j.jobref

Link to comment
https://forums.phpfreaks.com/topic/122555-please-help-with-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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