- Thanks received
- 0
Couldn't you just ring up all the customers and ask them if they have any orders? FFS, kids of today....
Generous of spirit and magnanimous in defeat. I salute you, sir.
SQL, eh? It can be tricky, can't it?
Couldn't you just ring up all the customers and ask them if they have any orders? FFS, kids of today....

I am not a coder but I have come across the phenomenon that some versions of some databases will do a tablescan when you are not expecting it, so you are earning your money by knowing when that will happen.
I would vote for the subquery option because it is the one that I would write, but I can accept that in the real world that could trigger a tablescan when it shouldn't. The foreign key should be indexed in both tables otherwise the DBA should be shot.
IMO
EDIT - even if all the fields are indexed that is not always enough to stop a tablescan.![]()
A left join usually sorts it all out.
A left join usually sorts it all out.
I have 2 tables, e.g. customers and orders. Foreign key between is customerID. I want to know which customers have zero orders.
What SQL will achieve this?
Thanks
