You're welcome!
Ooh, one last interesting thing. If both the "local" table and the "outer" table have a column with that name, SQL will use the "local" ("closer") table. For example:
CREATE TABLE #a ( col1 int, col2 int ) INSERT INTO #a VALUES(1,1),(2,2);
CREATE TABLE #b ( col1 int ) INSERT INTO #b VALUES(1);
SELECT * FROM #a a WHERE col1 IN (SELECT col1 FROM #b b);
--will list only col1=1, since that's all that appears in b.col1. But this:
SELECT * FROM #a a WHERE col2 IN (SELECT col2 FROM #b b);
--will list both 1 and 2; since #b doesn't contain col2, it's comparing to itself, as we've seen.
DROP TABLE #a
DROP TABLE #b
SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.