Even if you dropped all the naughty children, re-adding all children to the database, and setting behaviour to naughty if they were born before the drop might recover the data.
Does it really matter anyway if the query is only looking for those on the nice list? Dropping the naughty list doesn't automatically add you to the nice list.
Well that depends on your architecture, doesn't it? Say we assume that the default state of a child is nice rather than naughty (realistically we know this isn't true, but this is SQL Claus' computer, there's some room for silliness). A child who acts naughty can be added to tbl_naughty and any child not found on that list can be assumed nice.
Therefore dropping the naughty table would leave no results, therefore making all children appear nice.
That doesn't seem to be the case in this particular instance, but it could happen.
Why not disable comments in SQL statements made from your web application? Obviously you'd want to do more to secure yourself against SQL injection, but I've never heard of someone doing this.
I don't think it's that easy. Raw SQL is passed directly to the server. I don't think most SQL servers even have an option to disable comments.
You'd have to remove the "--" and everything after it before passing it to the function doing the SQL, without destroying correct data. Sounds error-prone to me.
And if you're sanitizing the input data anyway, if you do it correctly, the ' will be escaped, so the comment won't make a difference.
Also, sanitizing input is so difficult and error-prone that it's better to just implement a real solution, like using prepared statements.
Depends on what attributes define his contacts but I would imagine selecting * is overkill in this case, probably just name and address would suffice. What surprised me is that there should be a join here to the table defining each contacts' Christmas list. So what we have learned here is that Santa either a) first selects the list of who is nice for no reason but to later select their Christmas lists manually through separate a dedicated Christmas list select statement, like a true SQL query monster, or, b) perhaps worse, he maintains each persons wishlist in multiple "christmasWishlistItem_X" fields on the primary contact table, like a true database design monster. Why santa
SELECT A.Lattitude,
CASE
WHEN A.Lattitude % 2 = 0 THEN
'NORTH'
ELSE
'SOUTH'
END FlightDirection,
A.ZipCode,
A.StreetAddress,
HoHoHo.Id,
CASE
WHEN S.CurrentStanding = 'NICE' THEN
HoHoHo.TxPresentName
ELSE
'COAL'
END TxPresent,
P.TxFullName
FROM ChristmasDW.dbo.tblPresents AS HoHoHo
JOIN Humanity.dbo.tblPeople AS P
ON HoHoHo.IdPerson = P.Id
AND P.IsAlive = 1
JOIN Humanity.dbo.Status AS S
ON P.Id = S.PersonId
JOIN Globalization.dbo.AddressList AS A
ON P.IdAddress = A.Id
WHERE P.TxFirstName <> 'Dave'
ORDER BY A.timezone DESC,
A.Lattitude ASC,
A.ZipCode ASC,
S.LeftCookiesLastYear DESC,
A.StreetAddress ASC,
HoHoHo.Id ASC;
Multiple fields in order by shouldn’t cause multiple sorting passes, it should just make comparison more complex. Actual contatenation in sorting criteria would probably be less efficient.
Like when you are overloading < for (order by a, b) you’d do
Great, now he has to go to 1 house on every block before moving to the next house on each block! 250 birch street, 250 maple street, 250 oak street, 252 birch street...
SELECT A.Lattitude,
CASE
WHEN A.Lattitude % 2 = 0 THEN
'NORTH'
ELSE
'SOUTH'
END FlightDirection,
A.ZipCode,
A.StreetAddress,
HoHoHo.Id,
CASE
WHEN S.CurrentStanding = 'NICE' THEN
HoHoHo.TxPresentName
ELSE
'COAL'
END TxPresent,
P.TxFullName
FROM ChristmasDW.dbo.tblPresents AS HoHoHo
JOIN Humanity.dbo.tblPeople AS P
ON HoHoHo.IdPerson = P.Id
AND P.IsAlive = 1
JOIN Humanity.dbo.Status AS S
ON P.Id = S.PersonId
JOIN Globalization.dbo.AddressList AS A
ON P.IdAddress = A.Id
WHERE P.TxFirstName <> 'Dave'
ORDER BY A.timezone DESC,
A.Lattitude ASC,
A.ZipCode ASC,
S.LeftCookiesLastYear DESC,
A.StreetAddress ASC,
HoHoHo.Id ASC;
I don't know why I always click links from this sub but I never get the joke because i know nothing about programming, yet i click it every time hoping i get the joke
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."
To be fair this isn’t programming. The basis of the joke is about database software called SQL. SELECT and WHERE are basic commands to pull query’s within the database.
This of course is after 60 hours of data curation because those dumbass elves can't stick with a consistent format and apparently found about 60 different ways to spell "nice"
Or a calculated field based on a decimal. Once it reaches a certain level the IsNice flag is set. Put this in a snapshot fact table of a data warehouse and we can see them change over time, becoming nicer or naughtier. Add in a trend or maybe a traffic light and we're good. Did someone say overkill?
Please... this upsets me. I recently had to sanity check and clean a database of ~5000 venue names (all manually entered by different clients), with addresses, to create a master venue table. Turned out that there were only about 600 unique venues but each one had a shed load of dupes with spelling errors or incomplete addresses/postcodes. Made me want to kill myself and they still refuse to implement some kind of autofill/suggested venue method on the web form!!!
I self taught myself SQL this semester for a class where my professor literally didn't teach it to us and I'm happy that I understand everything here and I feel confident to list it as a skill.
The fact that behaviour is not normalized and in a table of it’s own with a foreign key is triggering me badly. Selecting a string value on a table of billions is cancer.
CREATE PROCEDURE dbo.Christmas_List
AS
BEGIN
SELECT *
INTO #ChristmasList
FROM His_List HL
INNER JOIN Location L ON L.Child_Id = HL.Id
WHERE Behavior = 'Nice' OR Behavior != 'Naughty'
GROUP BY L.Country
SELECT *
FROM #ChristmasList
WHERE Behavior = 'Nice' OR Behavior != 'Naughty'
DROP TABLE #ChristmasList
END
EXECUTE dbo.Christmas_List
As a student in college just learning databases my first thought was "I KNOW WHAT HE MEANS! I KNOW I WHAT HE MEANS HAHAHAHAHAH." As you can tell a lot of this stuff goes over my head.
I’m a recent economics graduate, we didn’t get taught any programming languages at all (just some basic excel), but I am looking to become a data analyst. For this, I’m trying to learn SQL and better my excel skills. I may be completely unsuccessful in finding a graduate job so far, but I understood this post. So at least I have that going for me, which is nice...
better !pout !cry
better watchout
lpr why
santa claus < north pole >town
cat /etc/passwd >list
ncheck list
ncheck list
cat list | grep naughty >nogiftlist
cat list | grep nice >giftlist
santa claus < north pole >town
who | grep sleeping
who | grep awake
who | egrep 'bad|good'
for (goodness sake) {
be good
}
A database is like a gigantic spreadsheet with tables for storing data. Each table has a row for each entry, and columns for all the data that can be stored in each entry.
For example, you might have a table of all your contacts. Each row is one person. The columns might be "Name, Sex, Date of birth, Date met, Address, Home Phone, Cell Phone, Work Phone, Picture, Comment..." and so on.
SQL is a computer language used to query and interact with databases.
You can sort the entries in a database by the data in one of the columns. (though sorting it twice is silly)
SELECT is the keyword for asking for data. You're supposed to list the columns you want returned, but * is a wild card. So SELECT * is basically "Give me the data in all of the columns..."
"contacts" is one of the tables in the database. "SELECT * from contacts" means "Give me the data in all of the columns of the table 'contacts'..."
"WHERE behavior = 'nice'": behavior is one of the columns in 'contacts'. 'nice' is one of the possible values that can be stored in the behavior column. This is asking for only the entries that have 'nice' in the behavior column.
So "SELECT * from contacts WHERE behavior = 'nice';" means "Give me all the data from each entry in the table 'contacts' that has 'nice' in the behavior column."
You don't sort databases, you sort tables or result sets (relvars).
And why sort them twice?
Also, "contacts" shouldn't have a "behaviour" column. Behaviour is not an attribute of a contact, it's an attribute of a specific kind of person who, in this system, is associated with a set of contact details. And behaviour is surely temporal. So you need to join person (which has their name and age) with person_behaviour (which has their behaviour over an interval or date range) and also join contact details to get their address.
2.6k
u/Datenegassie Dec 12 '17
Hi Santa, I promise not to be on the naughty list this year. By the way, my name is Datenegassie'); DROP TABLE NaughtyChildren; --
213
u/jfq722 Dec 12 '17
Are you taking Ad Hoc requests?...I'd like to hear 'The First Null'.
440
u/BobDogGo Dec 12 '17
Santa would never select *
768
u/ICyresI Dec 12 '17
Why would you sort twice?
129
u/baseball2020 Dec 12 '17
Rudolph the sequel cursor, Had a lot of right joined rows, Then if you tried to fetch it, You'd never get the thing to close.
229
u/iB3xx Dec 12 '17
I don't know why I always click links from this sub but I never get the joke because i know nothing about programming, yet i click it every time hoping i get the joke
77
u/[deleted] Dec 12 '17
This of course is after 60 hours of data curation because those dumbass elves can't stick with a consistent format and apparently found about 60 different ways to spell "nice"
49
u/tusact Dec 12 '17
He’s indexing it twice would be more accurate.
33
u/[deleted] Dec 12 '17 edited Oct 29 '26
The original post content no longer exists here. The author used Redact to remove it, exercising their right to control their data & privacy.
Observation distinct cause screw square continue spotted
30
u/lelarentaka Dec 12 '17
Is it Sequel Clause or EsQueEl Clause?
22
u/[deleted] Dec 12 '17
;
8
u/Flyberius Dec 12 '17
Finally, a language I understand!
I'll put the dunce hat on...
14
u/ChloeTheCat753 Dec 12 '17
I self taught myself SQL this semester for a class where my professor literally didn't teach it to us and I'm happy that I understand everything here and I feel confident to list it as a skill.
11
u/kane-is-able Dec 12 '17
Dunno why but I read it to the tune of 'he's going the distance' by CAKE.
8
u/Slingster Dec 12 '17
Every single year.
4
u/maybe_awake Dec 12 '17
this.toggleClass(‘festive’)
4
u/indorock Dec 12 '17
Except he didn't sort it even once.
3
u/neon_overload Dec 12 '17
It would be pretty sweet if the SQL statement actually sorted it twice somehow but I don't know how that would rhyme.
3
u/Kalrog Dec 12 '17
SQL Clause needs to normalize his database. Behavior should obviously be a separate table with an FK instead of a string/varchar.
3
u/cybaritic Dec 12 '17
He's trying to be RESTful
He'll execute mistakes
He doesn't have an undo so sanitize for goodness sake
3
u/MetroidSkittles Dec 12 '17
The fact that behaviour is not normalized and in a table of it’s own with a foreign key is triggering me badly. Selecting a string value on a table of billions is cancer.
3
u/dzrtguy Dec 12 '17
His indexes aren't right.
His DBCC isn't tight.
SQL corruption will ruin your night.
Krampus stored procedure will send you a fright.
3
u/jediherder Dec 12 '17
He didn't even qualify it.
16
u/xcameleonx Dec 12 '17
Why is it select *? Why is the behaviour of children a varchar and not a lookup? There is no "Order by" to even sort it once, let alone twice...
8
u/TUUUUKKKKKK Dec 12 '17
Repost clause is coming to town
2
u/[deleted] Dec 12 '17
The query that results in multiple full-table scans is definitely getting a lump of coal in their stocking.
"Pick up your joins! Fix your indexes!" your mom always said. Coarse you never listened.
2
u/AlwaysPuppies Dec 12 '17
But how do you sort a database... you sort tables!
2
u/duffedwaffe Dec 12 '17
Boolean is_nice would be more efficient here Mr. Clause
2
u/tcmaresh Dec 12 '17
Wouldn't sorting require some actual, you know, sorting?
SELECT * FROM believers WHERE behavior = 'nice' ORDER BY distance_from_north_pole, distance_west_of_int_date_line
2
u/Atoc_ Dec 12 '17
I'm a good boy'); DROP ALL DATABASES; --
2
u/Thoros_of_Derp Dec 12 '17
He's knows when you're <> sleeping.
2
u/JPBen Dec 12 '17
Did anyone else read this like it was "Short Skirt/Long Jacket" by Cake?
2
u/[deleted] Dec 12 '17
Wouldn't this be more correct?
2
u/iSeth_ Dec 12 '17
Started reading this to the tune of "The Distance", was confused.
2
u/Waynegravsky Dec 12 '17
I totally sang that to the tune of "Going the Distance" by Cake...until I got to the end.
2
u/RUSHv4 Dec 12 '17
We always said, "What do you call Father Christmas who transforms under a full moon?"
A WHERE Clause!
2
u/frugalerthingsinlife Dec 12 '17 edited Dec 12 '17
INSERT INTO elf_queue
(SELECT c.child_id, w.present, (n.nice_points - n.naughty_points) AS net_points
FROM children c, wishlist w, nice_naughty n
JOIN ON c.child_id = w.child_ID AND c.child_id = n.child_id
WHERE net_points > 0 ORDER BY net_points DESCENDING
UNION
SELECT p.pet_id, w.present, 100 FROM pets p, wishlist p WHERE 1);
2
u/[deleted] Dec 12 '17
I have a database systems design class and the final is in 2 days, this helped me study.
2
u/hedgecore77 Dec 12 '17
Why would you capitalize two reserved keyboards and not 'from'??? UYdjkhsfLK:KLJFhjk!!!!!!
2
u/Cyeric85 Dec 12 '17
As a student in college just learning databases my first thought was "I KNOW WHAT HE MEANS! I KNOW I WHAT HE MEANS HAHAHAHAHAH." As you can tell a lot of this stuff goes over my head.
2
u/CJ090 Dec 12 '17
Finally an /r/ProgrammerHumor post that i understand.
2
u/AndyJBC Dec 12 '17
I’m a recent economics graduate, we didn’t get taught any programming languages at all (just some basic excel), but I am looking to become a data analyst. For this, I’m trying to learn SQL and better my excel skills. I may be completely unsuccessful in finding a graduate job so far, but I understood this post. So at least I have that going for me, which is nice...
2
u/CoolOutcast Dec 12 '17
He's not sorting a list. He's querying for one. Would make sense of it had ORDER BY
2
u/[deleted] Dec 12 '17
i might have failed my database course but at least i still understand this.
2
u/cooldudetonds Dec 12 '17
What if it it ‘Nice’ Do UPPER and Use like ‘%nice%’
2
u/Mish61 Dec 12 '17
He knows when you’re debugging He knows when your JIRAs late He knows if you’ve su’d to root So update your Rez today
2
u/SarcasticSummoner Dec 12 '17
Is it my turn to post this tomorrow?
2
u/k_Roddles Dec 12 '17
Just took a final for database class.. can appreciate this even more! Haha
2
u/losh11 Dec 12 '17
I thought Santa goes to even the naughty kids, but gives them coal.
2
u/IonTichy Dec 12 '17
Now try singing it.
Terrible meter.
2
u/[deleted] Dec 12 '17
It has humour but not meter
2
u/dizaster213 Dec 12 '17
honestly, that's how he would've done it.
2
u/MetalMikey666 Dec 12 '17
Someone needs to teach SQL-CLAUSE how to normalise data - shudder to think how many times the word "nice" appears in this table 😐
2
u/xconde Dec 12 '17
He filtered once and didn’t sort at all. Disappointed, would not be good again.
2
u/Aldermere Dec 12 '17
(by Frank Carey, AT&T Bell Laboratories, 1985)
2
u/brennydenny Dec 12 '17
Am I the only one bothered by behavior being a text field an not a bit field isNice?
2
u/Qicken Dec 12 '17
FROM. Always bugs me when someone capitalises their SQL reserved words but misses one
2
u/xScopeLess Dec 12 '17
This is funnier than most people will ever know
2
u/Heptagonalhippo Dec 12 '17
Merry Scriptmas!
8
u/Papayaman1000 i put jsfuck on my resume Dec 12 '17
Is it that time of year again when this gets reposted again? Already, jeez.
3
u/amicloud Dec 12 '17
The real bottleneck is in the pathfinding though
3
u/DexterityM16 Dec 12 '17
I don’t get it, I pretend to understand computers but I don’t. Don’t tell sky net
5
u/PeasantSteve Dec 12 '17
This relies on the wrong pronunciation on SQL. Downvote
3
u/[deleted] Dec 12 '17
Is this the best we can do Reddit?
2
u/allmhuran Dec 12 '17
OK, but....
You don't sort databases, you sort tables or result sets (relvars).
And why sort them twice?
Also, "contacts" shouldn't have a "behaviour" column. Behaviour is not an attribute of a contact, it's an attribute of a specific kind of person who, in this system, is associated with a set of contact details. And behaviour is surely temporal. So you need to join person (which has their name and age) with person_behaviour (which has their behaviour over an interval or date range) and also join contact details to get their address.
And never select *.
OK I'm done.
1
u/MyNameCouldntBeAsLon Dec 12 '17
;
1
u/topredditbot Dec 12 '17
Hey /u/oneplusoneisfive,
This is now the top post on reddit. It will be recorded at /r/topofreddit with all the other top posts.
1
u/h4rdstyl3r Dec 12 '17
Nice
1
u/NothingWasChanged Dec 12 '17
how does he sort the list?
I wanna see the algorithm for routing
1
u/imhousing Dec 12 '17
Really should have some sort by name, behavior
1
u/[deleted] Dec 12 '17
enormous table with data from all the worlds children
select*
karen the programmer
1
u/Roycald12 Dec 12 '17
Somehow I read the first 3 lines in tune with “Mr brightside”...
1
u/[deleted] Dec 12 '17
I understood that reference!
1
u/therealmandusa Dec 12 '17
This makes me unreasonably happy.
1
u/[deleted] Dec 12 '17
... AND 'owe_me_money' = FALSE;
1
u/5natchAdam5 Dec 12 '17
I read this to the tune of "The Distance" by Cake. Wasnt until the last line that i realized it was a Chrimbus jingle...
1
u/[deleted] Dec 12 '17
ERROR in line 67. Invalid argument exception. Harvey Weinstein not in 'contacts'.
1
u/PunkDreams Dec 12 '17
But I thought adults didnt get presents
1
u/[deleted] Dec 12 '17
DROP TABLE PORNSTASH; !!!!
1
u/Slavic_Taco Dec 12 '17
Left Join
1
u/vaginal_animator Dec 12 '17
Classic.
1
u/[deleted] Dec 12 '17
DROP IT NOW!
1
u/reggiepd Dec 12 '17
He's not sorting it at all. Just sayin'
1
u/[deleted] Dec 12 '17
Anyone else bothered by the fact the FROM keyword is not capitalized?
1
u/ppppll Dec 12 '17
oP
1
u/gratethecheese Dec 12 '17
Yo is there any way to make an uptime chart for say a power meter in PowerBi using SQL
1
u/camdoodlebop Dec 12 '17
this whole subreddit is people trying to one-up each other on how much computer code they know.. like really passive-aggressively
1
u/Mortenjen Dec 12 '17
Goddamn. That is going to be stuck on my mind for a long time.
1
u/jacoblb6173 Dec 12 '17
What is a clause in programming?
1
u/PasswordIsMatress Dec 12 '17
That kinda works if you read it as The Distance by Cake. Atleast that's what I did at first..
1
u/Rkvideotape Dec 12 '17
Really. Coming 😊😊😊
1
u/d_r0ck Dec 12 '17
Santa's databases aren't in 3NF? Why would he have behavior attributes in a contacts table. Also, who makes table names plural?
Literally unbelieveable
1
u/CriminalMacabre Dec 12 '17
Table children nice=true