-
Notifications
You must be signed in to change notification settings - Fork 0
forgetful-elephant - 178 core sql solo #1
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
base: empty
Are you sure you want to change the base?
Conversation
| SELECT | ||
| name | ||
| FROM | ||
| student.student |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part looks fine, just wanted to comment that often in industry people would alias their tables here. E.g. "student.student s" would alias the table "s"
| FROM | ||
| student.student | ||
| JOIN | ||
| student.friend |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be aliased too (for example f, or t2)
| JOIN | ||
| student.friend | ||
| ON | ||
| student.student.id = student.friend.id1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here you could go s.id = f.id1
| FROM | ||
| student | ||
| AS | ||
| student1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine! Just a comment - It's okay to make short aliases, like s1, or s2, etc. to make typing easier.
| @@ -0,0 +1,16 @@ | |||
| INSERT INTO student VALUES (1510, 'Jordan', 9); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a workaround from loading the CSV file directly. Different database systems have different ways of doing this (copy, load data infile), but it'll be good for you to learn the methods because sometimes you'll end up having to work with big files, or you will be automating things and so you won't want to write the code by hand.
| ON | ||
| student.student.id = student.friend.id1 | ||
| WHERE | ||
| id2 = 1911 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spirit of this task is to query everyone who is friends with someone named Gabriel, so you would probably want the where clause to be on the name. Hardcoding it for the two student IDs of people named Gabriel is manual (so it's actually more work), and your query doesn't reflect the spirit of the question, and it will break if there are any new people named Gabriel. Ideally, someone would be able to tell what you're trying to do by reading your query.
No description provided.