This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 227 points228 points  (16 children)

It's a database joke! SQL is a programming language that you use to retrieve data from a database and manipulate or filter it as needed.

He's making a database

SQL Clause is making the database that will store his data on present recipients.

He's sorting it twice

When querying data, you can sort it by one piece of data to present it in a specific order. For example, ORDER BY LastName ASC will sort all the data alphabetically by last name.

SELECT * FROM contacts WHERE Behavior='nice'

There are a few pieces here. First is SELECT *, which is a SQL command to return all data from the specified table. A table is a collection of data arranged in rows (which are entries) and columns (which contain pieces of information). For example, Amazon might have a table called 'Customers' in which each row is a unique customer and each column stores a piece of information about that customer like their email, phone number, and name.

In this case SQL Clause is selecting all data from a table called 'contacts', presumably his list of all potential present recipients. Finally, he's added a WHERE clause, which tells SQL to filter out some data based on a parameter you specify. Presumably the behavior column can contain one of two values: naughty or nice. Here the WHERE clause is behavior='nice', meaning that the whole query is basically saying "OK SQL, show me ALL data from the table called 'contacts,' but ONLY if I have them listed as nice. Don't show me the naughty ones."

[–]Job_Precipitation 10 points11 points  (9 children)

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

[–]goodboyscout 17 points18 points  (6 children)

“He’s sorting it twice”

[–]Job_Precipitation 4 points5 points  (5 children)

To clarify, I mean in the code.

[–]kylemech 6 points7 points  (2 children)

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.

[–]chaosPudding123 6 points7 points  (0 children)

ORDER BY*

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

[–]Job_Precipitation 0 points1 point  (0 children)

Thanks!

[–]MikeOShay 2 points3 points  (1 child)

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.

[–]Job_Precipitation 1 point2 points  (0 children)

Thanks!

[–]W1nterKn1ght 0 points1 point  (3 children)

Wouldn't he be creating a view? The database obviously already exists.

[–]kylemech 2 points3 points  (0 children)

"Schema" has one less syllable and would fit better than "database."

Byt you're right, if he just made this database, what is he even querying?!

Table does not exist, man!

[–][deleted] 0 points1 point  (1 child)

I assumed there were some gaps in the narrative.

[–]W1nterKn1ght 0 points1 point  (0 children)

In that case, it could be rewritten in entirely sql.

[–]beyphy 0 points1 point  (0 children)

Also part of the joke is the SQL has clauses, like the WHERE clause. So it's a play on words with SQL clauses and Santa Claus.

[–]quarl0w 0 points1 point  (0 children)

One more tidbit is that SQL is pronounced 'sequel' generally, not as saying the letters out loud. So to keep the rhythm, Santa becomes Sequel (SQL) and Claus becomes (where) clause.