4 ms·
Agreed. Or at least put a table name in front of the asterisk: SELECT table1.*, table2.field FROM table1 JOIN table2 ON table2.rel_id =
by huuu 11y ago
Agreed. 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.