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
Checking Two Tables For Matching Records
Started by c_pattle, Dec 13 2012 10:55 AM
1 reply to this topic
#1
Posted 13 December 2012 - 10:55 AM
#2
Posted 13 December 2012 - 12:28 PM
SELECT o.order_id
FROM orders o
LEFT JOIN order_comments c USING (order_id)
WHERE c.order_id IS NULL
FROM orders o
LEFT JOIN order_comments c USING (order_id)
WHERE c.order_id IS NULL
Edited by Barand, 13 December 2012 - 12:28 PM.
|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts
|baaSelect| generate js and php code for dynamic linked dropdowns
|baaChart| easy line, column and pie charts
|baaSelect| generate js and php code for dynamic linked dropdowns
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users












