5 ms·
Not good enough, as 'select *' can in any event introduce ambiguity that is fatal to query processing.
by sk5t 5y ago
Not good enough, as 'select *' can in any event introduce ambiguity that is fatal to query processing.
- ted_dunning 5y agoDo you have an example to back that up?
- ted_dunning 5y agoIt actually appears to go the other way. Explicitly referencing an ambiguous column causes the error while using select * avoids it, at least with duckdb (which is a very standard sort of SQL). This suggests to me that using select * in views is a very good practice. D create table a (amb integer, a1 integer, a2 integer); D create table b (amb varchar, b1 integer, b2 integer); D insert into a values (1,1,1); D insert into b values ('b',2,2); D insert into b values ('b',1,3); D select * from a, b where a.a1 = b.b1; ┌─────┬────┬────┬─────┬────┬────┐ │ amb │ a1 │ a2 │ amb │ b1 │ b2 │ ├─────┼────┼────┼─────┼────┼────┤ │ 1 │ 1 │ 1 │ b │ 1 │ 3 │ └─────┴────┴────┴─────┴────┴────┘ D select amb from a, b where a.a1 = b.b1; Error: Binder Error: Ambiguous reference to column name "amb" (use: "b.amb" or "a.amb")
- listenallyall 5y agoThe database query analyzer is doing you a favor by telling you there's an ambiguous column name and refusing to run, for the same reason a compiler won't allow you to define the same variable name twice.