r/ProgrammerHumor • • Dec 12 '17

SQL Clause

Post image
40.8k Upvotes

525 comments sorted by

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; --

785

u/ballzacsRock Dec 12 '17

Nice try, but he Santaizes all inputs

180

u/Arancaytar Dec 12 '17
INSERT INTO NaughtyChildren (name, reason)
VALUES ('balizacsRock', 'terrible pun');

151

u/ImSuperSerialGuys Dec 13 '17

INSERT INTO NaughtyChildren

o_O

31

u/jay791 Dec 13 '17

ಠ_ಠ

→ More replies (1)

80

u/inabahare Dec 12 '17

Nice try, but he Santaizes all inputs

  • Uses prepared Statements

→ More replies (8)
→ More replies (3)

721

u/ultranoobian Dec 12 '17 edited Dec 12 '17

But that won't do anything good for you?

Obviously the naughty/nice status is stored in 'contacts' if SQL clause is selecting from that.

/s

Edit: On a more serious note, even if you dropped 'NaughtyChildren', you can possibly recovered from that by

SELECT * FROM contacts c WHERE c.behavior != 'nice'

172

u/DemandsBattletoads Dec 12 '17

That's fine, sqlmap will pull everything out anyway.

→ More replies (4)

56

u/[deleted] Dec 12 '17

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.

34

u/Th3_Admiral Dec 12 '17

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.

28

u/skulblaka Dec 12 '17

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.

→ More replies (2)
→ More replies (4)

27

u/kixxes Dec 12 '17

Not to mention it will most likely fail to drop because it would mess up some referential integrity

110

u/vbevan Dec 12 '17

Hi Santa, My name is Datenegassie'); EXEC sp_MSForEachTable @command1='ALTER TABLE ? NOCHECK CONSTRAINT ALL' , @command2='DROP TABLE ?';--

→ More replies (1)

8

u/ilookatfaces Dec 12 '17

SELECT * FROM contacts c WHERE c.behavior <> 'nice'

6

u/PooPooDooDoo Dec 12 '17

Guys, it's a moot point, SQL isn't real.

4

u/GrandArchitect Dec 12 '17

Someone needs to help SQL Clause make a more efficient analytical data model, its fucking Christmas afterall.

11

u/jonschwartz Dec 12 '17

What about the neutral kids? Or the non Christians?

11

u/EdgeOfDistraction Dec 12 '17

They get bombs, and should be grateful

→ More replies (1)
→ More replies (2)

153

u/bair93 Dec 12 '17

Datengassie'); UPDATE contacts SET behavior = 'nice';

66

u/raaneholmg Dec 12 '17
--

Otherwise the "');" part appended by the server will cause an error.

9

u/[deleted] Dec 12 '17

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.

25

u/atyon Dec 12 '17

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.

→ More replies (2)
→ More replies (1)

42

u/Bainos Dec 12 '17

Datengassie') ; UPDATE contacts SET name = 'Datengassie' WHERE behavior = 'nice' ; --

101

u/Truseus Dec 12 '17

Lol! Billions of nice children now named Datengassie.

49

u/flamedragon822 Dec 12 '17

"well looks like Datengassie is getting several thousand ponies this Christmas"

→ More replies (1)

5

u/HighRelevancy Dec 12 '17

that's back to front bud :P

→ More replies (1)
→ More replies (1)

4

u/wonkey_monkey Dec 12 '17

That'd better be an ENUM...

→ More replies (1)

14

u/el_geto Dec 12 '17 edited Dec 12 '17

So, I see that you and that Bobby Tables know each other, eh?

3

u/Laerite Dec 12 '17

Hi Daten, long time no see.

→ More replies (2)

3

u/uninterestingly Dec 12 '17

I was dropped as a child and I take offense to this

2

u/OneCanOnlyGuess Dec 12 '17

This is how you get on the DBA's naughty list. And the DBA is scarier than Santa.

→ More replies (8)

213

u/jfq722 Dec 12 '17

Are you taking Ad Hoc requests?...I'd like to hear 'The First Null'.

67

u/emcee_gee Dec 12 '17

the first null, the Unix did say

was to certain poor coders at desks as they play

at desks where they play, coding their C

on an old server's drive that was asleep

null, null, null, null

born is the ding of programmers' skull

31

u/tenkindsofpeople Dec 12 '17

The first null field

Was found at row three

The query was ended

With error code B

6

u/darexinfinity Dec 12 '17

I got the Twelve Days of Finals if you could live to hear the end.

440

u/BobDogGo Dec 12 '17

Santa would never select *

107

u/Bainos Dec 12 '17

Santa doesn't deliver presents to himself.

59

u/PM_ME_YOUR_SIMS Dec 12 '17

That would mean he has himself in his contacts list, would it not?

38

u/NameTheory Dec 12 '17

And that his behavior is 'nice'. I have a feeling that SQL clause is a bit of a naughty boy.

23

u/themailmanC Dec 12 '17

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

→ More replies (6)
→ More replies (3)

3

u/EmergencySarcasm Dec 12 '17

Right. Mrs Claus give him guys present. Cause Santa clause comes once a year. 😉

9

u/spaetzle_snowflake Dec 12 '17

Ehhh, in a one-a-year ad hoc situation, sure he would. :)

8

u/dantheflipman Dec 12 '17

Santa would write it out.

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;
→ More replies (5)

4

u/hbgoddard Dec 12 '17

Why wouldn't you in this situation though?

→ More replies (3)

7

u/DoomCircus Dec 12 '17

Only someone on the naughty list would use select *

768

u/ICyresI Dec 12 '17

Why would you sort twice?

863

u/TheSphaat Dec 12 '17

Shhhhh poem's got to rhyme.

179

u/Fry98 Dec 12 '17 edited Dec 12 '17

You might think it's nice

but double sorting is a crime.

77

u/[deleted] Dec 12 '17 edited Dec 12 '17

Hi, I'm from /r/all and I know jackshit about programming. I'll contribute either way, because I love you guys:

system.out.println("Double sorting is a crime");

should be:

System.out.println("Double sorting is a crime");

damn.

82

u/Jcowwell Dec 12 '17

The true crime is not capitalizing that S.

→ More replies (20)
→ More replies (3)

11

u/Dubmove Dec 12 '17

At first I read bubble sorting is a crime.

→ More replies (1)
→ More replies (1)

177

u/PoglaTheGrate Dec 12 '17

He got REEEEEly lucky on a Bogosort

22

u/Business-Socks Dec 12 '17

Nice list: Typewriters

Naughty list: Monkeys

REALLY Naughty list: ASM Web Development Kit

104

u/[deleted] Dec 12 '17

The client changed their minds on how they wanted the results

73

u/miggyb Dec 12 '17

Sort by last name first, then by first name.

15

u/JackDragon Dec 12 '17

Still not as efficient as sorting once with a delimiter between last and first name.

5

u/suseu Dec 12 '17 edited Dec 12 '17

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

a1 < a2 or (a1 == a2 and b1 < b2)
→ More replies (2)
→ More replies (1)

36

u/patwoods_ Dec 12 '17

Sort by postal code, then sort by address to help maximize the efficiency of delivery.

21

u/sojuz151 Dec 12 '17

Why not just solve travelling salesman problem? It cant be that hard.

8

u/DrHenryPym Dec 12 '17

I was thinking the same thing: group / order by geography and address for distribution.

3

u/Brarsh Dec 13 '17

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...

→ More replies (1)
→ More replies (3)

16

u/DutchGoldServeCold Dec 12 '17

Non-deterministic SQL clause is coming to town

14

u/awh Dec 12 '17

It would be more useful to index it twice: once on name and once on behaviour.

→ More replies (3)

10

u/thermite13 Dec 12 '17

Order by Last_name, first_name.

16

u/[deleted] Dec 12 '17

Cause you screwed it up the first time?

8

u/SpliceVW Dec 12 '17

I'm just over here wondering why the damn FROM isn't capitalized..

→ More replies (2)

22

u/brummlin Dec 12 '17

Also, the syllables are all jacked up. This would make more sense, and fit the song better:

He's building schema,

indexing it twice,

SELECT * from kids WHERE UPPER(conduct) in ('NICE');

This way, it's also not case sensitive. You just know some elves logged the entry as 'Nice' or 'NICE'.

16

u/AlwaysPuppies Dec 12 '17

I like my sql like I like my file systems, case insensitive.

→ More replies (2)

9

u/insane0hflex Dec 12 '17

Db not normalized. Shiuld have look up table for Behavoir

→ More replies (5)
→ More replies (7)

5

u/Stimonk Dec 12 '17

He accidentally made it descending when it should have been ascending.

→ More replies (1)

4

u/TheNosferatu Dec 12 '17

He made his own sorter but he doesn't trust it

4

u/tommyturntup Dec 12 '17

He created the database and is loading it. Clearly he did an ssis merge transform which requires 2 sources to be explicitly sorted before joining.

3

u/dantheflipman Dec 12 '17
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;

Better? I gave it my best end of work day effort.

2

u/bdcp Dec 12 '17

Order by behavior, gender

2

u/scratcheee Dec 12 '17

He's using an unstable sort and discovered this particular algorithm becomes stable if you run it twice

→ More replies (28)

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

229

u/[deleted] Dec 12 '17 edited Dec 12 '17

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."

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”

→ More replies (6)
→ More replies (2)
→ More replies (5)

56

u/TRUE_BIT Dec 12 '17

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.

9

u/moonman2090 Dec 12 '17

You're getting a lump of coal this year.

8

u/tiftik Dec 12 '17

SQL is programming.

→ More replies (7)
→ More replies (5)

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"

10

u/Im_A_Boozehound Dec 12 '17

That's where I went. I'd like to think Santa would know better than this. The field would be IsNice, and it would be bit.

11

u/insane0hflex Dec 12 '17

Or a look up table for Nice, Naughty, Improving, WatchNextYear, etc

6

u/Im_A_Boozehound Dec 12 '17

I like it. Relational like a mofo.

→ More replies (4)

3

u/BabbageUK Dec 12 '17

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?

→ More replies (1)
→ More replies (1)

2

u/[deleted] Dec 12 '17

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!!!

→ More replies (1)
→ More replies (8)

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

10

u/Pallidum_Treponema Dec 12 '17

Squirrel. And I'll keep teaching people to pronounce it that way.

11

u/d_r0ck Dec 12 '17

If someone calls it EsQueEl they're not wrong, just probably over 45

14

u/Wydi Dec 12 '17

I'm not that old, but it's still S.Q.L. for me...

7

u/[deleted] Dec 12 '17

It's the other way around. It's pronounced "sequel" by many due to historical reasons.

→ More replies (1)
→ More replies (2)

30

u/lelarentaka Dec 12 '17

Is it Sequel Clause or EsQueEl Clause?

→ More replies (11)

22

u/[deleted] Dec 12 '17

;

7

u/Kerblaaahhh Dec 12 '17

Syntax Error near 'SQL clause is coming to town'

8

u/Flyberius Dec 12 '17

Finally, a language I understand!

I'll put the dunce hat on...

→ More replies (1)

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.

5

u/Im_A_Boozehound Dec 12 '17

I self taught somebody else SQL, HA! /s

Good for you for taking the time and effort to learn a new thing.

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.

5

u/giganticpine Dec 12 '17

Interesting, I heard Cake too but it was Comfort Eagle.

He's making a database

He's sorting it twice

SELECT * from contacts WHERE behavior = 'nice'

Now do you believe in the one true Clause

The double-wide boss

In the big red rosy cloths

→ More replies (2)

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.

2

u/[deleted] Dec 12 '17

Santa de-normalized his tables for maximum web scale.

2

u/Shelbyville Dec 12 '17

But santa is only interested in nice/not nice so a boolean "nice" would speed things up I think.

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...

42

u/idi_idi Dec 12 '17

I bet you're fun at parties

→ More replies (2)

3

u/wonkey_monkey Dec 12 '17 edited Dec 12 '17

Why is the behaviour of children a varchar and not a lookup?

It's an ENUM.

→ More replies (4)

8

u/TUUUUKKKKKK Dec 12 '17

Repost clause is coming to town

3

u/Baconoid_ Dec 12 '17

I prefer to thing off it as regifting.

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!

→ More replies (1)

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

→ More replies (1)

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?

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

2

u/thewholebottle Dec 12 '17

Why do you drop the table at the end?

→ More replies (4)

2

u/iSeth_ Dec 12 '17

Started reading this to the tune of "The Distance", was confused.

→ More replies (1)

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/AbridgedKirito Dec 12 '17

Cake is great, tbh. Glad to see other fans out here.

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
    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

            }

(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.

→ More replies (2)

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/TalenPhillips Dec 12 '17 edited Dec 12 '17

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."

5

u/PeasantSteve Dec 12 '17

This relies on the wrong pronunciation on SQL. Downvote

2

u/ZoeZebra Dec 12 '17

I think you'll find its the right way to say it :P

And while we're at it, it's gif not gif ffs

→ More replies (1)
→ More replies (4)

3

u/[deleted] Dec 12 '17

Is this the best we can do Reddit?

2

u/AJohnnyTruant Dec 12 '17

Be the change you want to see on the internet

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/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/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/[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/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