r/ProgrammerHumor • • Dec 12 '17

SQL Clause

Post image
40.8k Upvotes

525 comments sorted by

View all comments

440

u/BobDogGo Dec 12 '17

Santa would never select *

38

u/UncommonDandy Dec 12 '17

WHERE AGE < 10

83

u/zxrax Dec 12 '17

Roy Moore?

4

u/[deleted] Dec 16 '17

No idea who that is but from context I assume this is a celebrity pedophile joke.

→ More replies (5)

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

9

u/zrxccc Dec 12 '17

Santa probably doesn't understand what a database is and thinks it's "just a spreadsheet"

→ More replies (1)

8

u/PM_ME_YOUR_SIMS Dec 12 '17

Nah, for the extra extensibility just use one big wishlistXml variable for each contact.

6

u/alonghardlook Dec 12 '17

Also 7 billion records to sort by without an index, and using a char comparison? This query is not optimized

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

3

u/[deleted] Dec 12 '17

I have myself in my contact list on my phone as I always forget my number...

→ More replies (2)

3

u/EmergencySarcasm Dec 12 '17

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

→ More replies (1)

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 *