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 Quote Link to comment Share on other sites More sharing options...
Barand Posted December 13, 2012 Share Posted December 13, 2012 (edited) SELECT o.order_id FROM orders o LEFT JOIN order_comments c USING (order_id) WHERE c.order_id IS NULL Edited December 13, 2012 by Barand Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.