I noted that, when executing joins, MSSQL
will throw "Invalid Column Name" if the table you are joining on is not next to the table you are joining to. I tried specifying table1.row1
and table3.row3
, but was still getting the error; it did not go away until I reordered the tables in the query. Apparently, the order of the tables in the statement matters.
+-------------+ +-------------+ +-------------+
| table1 | | table2 | | table3 |
+-------------+ +-------------+ +-------------+
| row1 | col1 | | row2 | col2 | | row3 | col3 |
+------+------+ +------+------+ +------+------+
| ... | ... | | ... | ... | | ... | ... |
+------+------+ +------+------+ +------+------+
SELECT * FROM table1, table2 LEFT JOIN table3 ON row1 = row3; --throws an error
SELECT * FROM table2, table1 LEFT JOIN table3 ON row1 = row3; --works as expected