Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

After years of doing that same technique, in my new job, people would write:

   SELECT foo.id, quux.value
   FROM foo, quux, bar
   WHERE foo.bar_id = bar.id AND bar.quux_id = quux.id
I couldn't find anyone telling me the difference between those 2 ways to write a query, do someone know more about this?


There's no performance difference in the engine.

The way you have written it (ANSI-89)used to be the only way joins could be written.

The second one (ANSI-92) was introduced to allow for composability since the entities being joined and the join condition are next to each other in the code and multiple joins can be generated one after the other.

IMO it also enhances developmemt quality of life since you can understand a new-to-you query faster (especially complex ones), you can just comment out a join in one line when testing replacement, cut and paste between queries easier, etc.

An SO question on the topic

https://stackoverflow.com/questions/334201/why-isnt-sql-ansi...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: