Quote:
|
Originally Posted by zeolite
When I execute some SQL similar to the following I get an error message saying that sub-selects are not supported on joins. I cannot work out whether there is a logical reason for this or it is just a limitation of my DBMS.Any thoughts?
|
The columns you specify for an inner join are supposed to be columns the DBMS can use to match rows between tables. What you're trying to do is filter rows, so it should be in a WHERE clause. (Or a HAVING clause...)
Keep in mind that any SELECT foo FROM a JOIN b ON a.x = b.x is simply syntactic sugar for SELECT foo FROM a CROSS JOIN b WHERE a.x = b.x. Recall that CROSS JOIN means "find all possible combinations of rows", but once you restrict the results to only those rows with a matching column, you get a regular inner join. That's why it works the way it does.