Question about aliases on SELECT
(1) By doug (doug9forester) on 2020-06-02 00:32:47 [source]
Given this select:
SELECT t1.a AS a1 FROM t1 AS ta WHERE t1.a = ...
I sort of expected an error, because I should have coded the WHERE as:
SELECT t1.a AS a1 FROM t1 AS ta WHERE ta.a1 = ...
But no error. Can I assume that both forms of WHERE are valid and yield the same results?
(2) By Keith Medcalf (kmedcalf) on 2020-06-02 03:24:50 in reply to 1 [link] [source]
In this case, yes, because you have no ambiguities.
select t1.a as a1 from t1 as ta, t1 as tb, t1 as tc where t1.a = 47
To which t1.a does t1.a refer?