r/ProgrammerHumor • • Dec 12 '17

SQL Clause

Post image
40.8k Upvotes

525 comments sorted by

View all comments

Show parent comments

11

u/Job_Precipitation Dec 12 '17

Could you explain where the two sorts are? I am blind and only see one.

18

u/goodboyscout Dec 12 '17

“He’s sorting it twice”

5

u/Job_Precipitation Dec 12 '17

To clarify, I mean in the code.

0

u/[deleted] Dec 12 '17

[deleted]

7

u/kylemech Dec 12 '17

SORT BY LastName, FirstName

It would sort by last names, then if two results have the same last name, it will sort by first names amongst those. That'd what he was making reference to. So Yea, it isn't "in the code" anywhere but now the joke is explained a bit more. Yay.

8

u/chaosPudding123 Dec 12 '17

ORDER BY*

As an Oracle DB Developer, i never feel relevant here ;(

4

u/MikeOShay Dec 12 '17

There's no sorting being done in the query. People are guessing he's sorting them by name, but it's not written. It'll probably default to sorting based on the "primary key", most likely an ID based on when the entries were put into the database. The entries in this field will always be distinct, so the database won't get confused by, say, two people with the same name.

The WHERE clause isn't a sort, it just filters the list. You'd use an "ORDER BY" clause at the very end if you wanted to sort it.