3 ms·
>it's hard to keep track which value came from where Isn't that dependent on how you write the query? If you put the table name or it's alias before the column
by croes 4y ago
>it's hard to keep track which value came from where
Isn't that dependent on how you write the query? If you put the table name or it's alias before the column it's quite easy to keep track of the data source.
- obi1kenobi 4y agoTry it with a query that has 40 joins with multiple joins to the same table from different places, and let me know if you still think it's easy :) At work I've seen SQL queries that are thousands of lines long that would make that 40-join query look like a toy example.
- fknhellmyas 4y agoThat's what I always tell people advocating for plastic straws. They think plastic straws are great, they drink their cocktails with them and everything. Then I tell them how when I try to wash my cars by assembling 50 straws into a water hose, the whole plastic straw concept quickly breaks down. In my opinion you should never use plastic straws.
- croes 4y agoThat's exactly what I do and why aliases exist. It's manual effort, but that's documentation always.
- Izkata 4y agoI mean, they're also talking about using the same table multiple times - aliases aren't just useful, they're required in that case so the engine knows which one you mean when using a column from one of them. Best guess without actually seeing these queries, whoever wrote them is using bad aliases (like "foo1", "foo2" and so on) instead of something more reasonable.
- ako 4y agoBest not to have a single query, but to break it down into a number of separate views and join those views for your final query.