Running Mysql,
Three tables. estimate_request, proofs, and _artists
Relationships:
estimate_request -> proofs : 1 to many or none
estimate_request -> artists : one to one or none
My query must select all from _estimate_request where status = active, the associated artist is any, AND the most recent proof record (if any) based on the column action_date.
The following gives me all desired records PLUS a duplicate where there are more then one entry in the proof table for a given estimate_request record.
SELECT *
FROM estimate_request e
LEFT OUTER JOIN proofs p ON e.estimateID = p.estimateID
LEFT OUTER JOIN _artists a ON e.artistID = a.ID
WHERE
e.status='Active'
Hope this makes sense.
Thanks
KEith