c_pattle Posted December 13, 2012 Share Posted December 13, 2012 I was just wondering if anyone knows what the most efficient way of checking to see if two tables contain matching records. So for example I have a table called 'orders' which have a primary key of order_id. Then I have a table called 'order_comments' which also has a field called order_id and I want to run a query that will check which orders don't have entries in order_comments. Thanks for any help Link to comment https://forums.phpfreaks.com/topic/271963-checking-two-tables-for-matching-records/ Share on other sites More sharing options...
Barand Posted December 13, 2012 Share Posted December 13, 2012 SELECT o.order_id FROM orders o LEFT JOIN order_comments c USING (order_id) WHERE c.order_id IS NULL Link to comment https://forums.phpfreaks.com/topic/271963-checking-two-tables-for-matching-records/#findComment-1399218 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.