Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple JOINS - style and legibility #191

Open
pgmccann opened this issue Aug 22, 2017 · 0 comments
Open

Multiple JOINS - style and legibility #191

pgmccann opened this issue Aug 22, 2017 · 0 comments

Comments

@pgmccann
Copy link
Contributor

@pgmccann pgmccann commented Aug 22, 2017

[Currently completing Instructor checkout]

I'm not sure if this is simply a matter of personal preference, but the way in which the example of multiple joins in Combining Data is written looks odd to me:

SELECT Site.lat, Site.long, Visited.dated, Survey.quant, Survey.reading
FROM Site JOIN Visited JOIN Survey
ON Site.name=Visited.site
AND Visited.id=Survey.taken
AND Visited.dated IS NOT NULL;

I would write:

SELECT Site.lat, Site.long, Visited.dated, Survey.quant, Survey.reading
FROM Site
JOIN Visited ON Site.name=Visited.site
JOIN Survey ON Visited.id=Survey.taken
WHERE Visited.dated IS NOT NULL;

Again, I'm not sure to what extent this is down to personal style, but I believe this is more legible. Moreover, placing the ON conditions next to the corresponding joins fits better with the incremental building of queries discussed in previous episodes. In my experience, it's also more likely to be more similar to examples learners may find online.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.