I have three tables - node, content_type_product and share_content. There may be a 1:N relationship beetween node and share_content. I want to pull out only one record per id. If there is multiple records in share_content, I want the latest one, that is the highest value of sc.auto_id
SELECT sc.uid, n.uid, n.nid, sc.message
FROM node n
LEFT JOIN content_type_product p ON n.nid = p.nid
LEFT JOIN share_content sc ON n.nid = sc.nid
WHERE n.nid = 40513
GROUP BY sc.nid
ORDER BY sc.auto_id