2 ms·
> the field will be automatically deduplicated, so you don't have to qualify it elsewhere in the query, and "SELECT " will return only one copy. You still have
by ComodoHacker 11y ago
> the field will be automatically deduplicated, so you don't have to qualify it elsewhere in the query, and "SELECT " will return only one copy.
You still have in outer joins. Also, SELECT * is a bad practice (with some exceptions) when used in code, suitable only for ad-hoc queries.
- huuu 11y agoAgreed. Or at least put a table name in front of the asterisk: SELECT table1.*, table2.field FROM table1 JOIN table2 ON table2.rel_id = table1.id
- ComodoHacker 11y agotable.* doesn't really do any better. Database evolves, table's structure changes and you get various bugs and unpredictable behavior. From elusive exceptions to memory hogs to network bottlenecks, depending on DBMS, data itself and data access framework you use.
- huuu 11y agoIt does better when, for example, you have a field called 'id' in both tables. SELECT * FROM table1 JOIN table2 ON table2.rel_id = table1.id will use one of the 'id' field from table1 or table2 (depending on the join type). SELECT table1.* FROM table1 JOIN table2 ON table2.rel_id = table1.id will use the 'id' field of table1 and does not include data from table2. But I agree with your other arguments.