will this query alternative to join (simple) work?
the link is http://www.sqlcommands.net/sql+join/
i would like to know if it would work if 开发者_如何学Cit were
SELECT Weather.City
FROM Weather
WHERE Weather.City = State.City
meaning select all those cities "from weather" which belong in the state table
will the above work if not then why?
No because to use State.City, the table State needs to be somewhere in the FROM list.
The alternate to the example you provided would be:
SELECT Weather.City
FROM Weather
INNER JOIN State
ON Weather.City = State.City
Your query won't work because the table State
does not appear in the FROM clause so you can't reference its columns.
This would work though:
SELECT Weather.City
FROM Weather
JOIN State
ON Weather.City = State.City
or, as an alternative (using yr english sentence as a guide):
SELECT City -- select all those cities
FROM Weather -- "from weather"
Where City In -- which
(Select City From State) -- belong in the state table
精彩评论