Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

SQL "using keyword from"

suppose we have course records in database.
what is the point using this:

select k.ID from course k

and not this, (straight):

select course.ID

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The case is when you do not have a degenerate simplistic edge case (which, agreed, is not really an edge case here).

Imagine you have joined course TWICE (or more). Been there, seen that. How do you think SQL will distinguish between both "course" instances? course.ID may suddenly not be unique – after all, there are now 2 (or more) course tables joined in in the from clause, with different join conditions.

Exactly. You NAME them in the FROM, then you can use the now unique identifier.

And yes, I have been in situations where I had to join the same table multiple times.

So, as you can see, there is a use case.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading