I have three tables - node, content_type_product and share_content. There can be a 1: N ratio between the node and share_content relationships. I want to pull only one record per identifier. If there are multiple entries in share_content, I want the latter, i.e. the highest sc.auto_id value
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
source share