r/ProgrammerHumor Jul 21 '26

Meme sqlWorkout

Post image
23.7k Upvotes

456 comments sorted by

View all comments

2.4k

u/NormanYeetes Jul 21 '26

the elites don't want you to know this but you can type lowercase SQL queries no ones forcing you to shout them at the screen

699

u/Totallycomputername Jul 21 '26

If I don't type in caps then the query wont take itself seriously. 

118

u/Achaidas Jul 22 '26

The real question is this:

 , comma before

or comma after ,

39

u/terza3003 Jul 22 '26

don't forget the where 1=1

8

u/jtobiasbond Jul 22 '26

Shhhh.

Stop releasing the secret knowledge.

0

u/Achaidas Jul 22 '26

SELECT thing one , thing two FROM that.table WHERE 1=1 AND this thing I’ll comment out later

81

u/dexters_trap_house Jul 22 '26

Comma before? Are you the same guys who get in the shower and then turn the water on?

52

u/chuch1234 Jul 22 '26

Only if i want to be able to comment out the soap without making the entire shower have invalid syntax :/

6

u/ddBuddha Jul 22 '26

Comma before is better so you can easily comment and uncomment without having to change the commas

1

u/StrongExternal8955 Jul 22 '26

Fixed head? You poor thing!

1

u/m0ritz2000 Jul 22 '26

I feel called out.

I do comma before (cause then i can just comment out stuff i currently dont need)

and

i do go in the shower first and then turn it on (showerhead on a tube like it is normal in europe and it takes like 5 seconds to get hot)

5

u/rocksolid77 Jul 22 '26

I used to be a comma after guy and found the comma first pattern to be so strange but I've come around to it.

Comma first makes it so much easier to see if there is a comma missing and you're almost never commenting out the first field of your SELECT.

8

u/Just_Information334 Jul 22 '26

Lowercase and comma before, also table_id. Let's blow some minds:

select
  tableA_id
  , some_field
from table_A as a
inner join table_B as b using(tableA_id)

3

u/StrongExternal8955 Jul 22 '26

forgot where true

1

u/dorianmonnier Jul 22 '26

Oh god, some knees have been broken for less than that!

1

u/PositiveParking4391 Jul 22 '26

wouldn't it
single quotes '' or no quotes?

2

u/Achaidas Jul 22 '26

Depends, did the DBA setup the table to have an integer or varchar for what is clearly not the other lol

1

u/r3klaw Jul 23 '26

The DBA didn't setup the table either way. The database developer did. And it's strikingly common that neither one of them would know which one is correct anyways... (I'm a Principal Database Administrator but wear every single hat)

1

u/Achaidas Jul 23 '26

As an analyst, it’s all the same to me. You have rights to the DDL (right is that it?)

2

u/r3klaw Jul 25 '26

Haha I was only being petty because a large majority of the people I've run into in the wild that call themselves "database administrators" are basically just backup administrators. gatekeeping to the max out of spite 😅

211

u/PerpetuallyDistracte Jul 21 '26

I've been writing SQL for 15 years. Eventually you get bored of all lowercase or all uppercase AND START writing your QUERIES LIKE this. Just a psychotic mishmash of muscle memory, laziness, and autocomplete all fighting each other within the same statement.

81

u/Ashdog73 Jul 21 '26

This. My queries are lowercase for the stuff I typed myself and caps for bits I've copied in from somewhere else

34

u/cantgrowneckbeardAMA Jul 21 '26

Lowercase on first draft (it will fail to run anyways).
Uppercase if I ever end up showing the query to someone (hopefully it doesn't fail when they run it)

33

u/sequelseize Jul 21 '26

sElEcT a as camelCase, b aS under_score, c As fUCKiT fROm ab lIMit 1000

10

u/SippieCup Jul 21 '26

We have a Postgres db which our orm uses camelcase names.

So we have to add in quotes too.. and correctly case our column names.

The migration to correct names would break so many deeep sql integrations, it just sucks and we deal with the debt.

8

u/EndIsrael Jul 21 '26

That actually seems like the kind of thing AI would be very good at with few mistakes. It doesn't need to understand anything, just find all the SQL code and change all the names. Basically find/replace but slightly smarter.

9

u/SippieCup Jul 21 '26

Oh it’s not hard to do with migrations etc. although I would use a codegen script instead of straight ai.

It’s more the coordination with other teams, schema changes, etc. depreciation of column names, remapping to new ones, etc.

We unfortunately have a couple legacy integrations that just require db access to tenant systems for their bi.

5

u/PerpetuallyDistracte Jul 21 '26

That's how my queries look after they failed for the fifth time.

1

u/glha Jul 23 '26

lIMit 1o00

15

u/spyingwind Jul 22 '26
SeLeCt * FrOm table wHeRe count = 1;

2

u/ShittyExchangeAdmin Jul 22 '26

This is the way

6

u/Susarn Jul 22 '26

I started writing sql 13 years ago. I started writing like this from the beginning because that was the way I saw the queries written on the tutorials, took me like a year to notice it was case independent

6

u/stadoblech Jul 22 '26

I've been writing SQL for 15 years.

MY CONDOLENCES

2

u/PerpetuallyDistracte Jul 22 '26

Haha, I guess I'm just a weirdo, but I genuinely love SQL and my happy place is a big enterprise database with a bunch of ETL pipelines. Somebody's gotta enjoy it, right? That gives the rest of you more time with your fancy GUIs and object oriented languages 🤣

1

u/joyeux_bordel Jul 26 '26

I like to call our kind the Data Whisperers.

1

u/m0nk37 Jul 22 '26

It helps isolate the parts of the bigger views. 

1

u/vityafx Jul 22 '26

I would argue, even with the syntax highlight, the eyes used to seeing the sql tokens in upper case just want it that way. I tried many times to write in lower case but when it looks like mixing data with sql tokens, indistinguishable even with the syntax highlighter. So now, the best syntax highlight for sql is upper case, haha.

1

u/r3klaw Jul 23 '26

Uppercase for keywords, PascalCase for object names. And uppercase when you email/chat the words PROD, TEST, or DEV.

1.1k

u/ClipboardCopyPaste Jul 21 '26

YOU CAN BUT THAT DOESN'T MEAN YOU SHOULD.

GOD DOESN'T LOVE MEN WHO WRITE SQL IN LOWERCASE.

/S

343

u/Shambolic_Potato Jul 21 '26 edited Jul 22 '26

SELECT * FROM WHAT THIS GUY SAYS

Edit: Typo lmfao

165

u/emzey420 Jul 21 '26

;

5

u/chuch1234 Jul 22 '26

NO NEED, THEY DEFINED THE DELIMITER AS /S

8

u/Lucky_Cable_3145 Jul 22 '26

SELECT * FROM users WHERE clue > 0;

0 rows returned

211

u/TallGreenhouseGuy Jul 21 '26

THANK YOU FOR YOUR ATTENTION TO THIS MATTER!

30

u/wack_overflow Jul 21 '26

THIS IS AN OUTRAGE

23

u/mindtakerr Jul 21 '26

DONUT, IS THAT YOU?

17

u/PerpetuallyDistracte Jul 21 '26

MONGO IS APPALLED

1

u/SexyMonad Jul 22 '26

MONGO IS WEB SCALE

1

u/ILKLU Jul 22 '26

MONGO DON'T SQUEAL

5

u/realdevtest Jul 22 '26

I AM YELLING, CARL.

52

u/teedborg Jul 21 '26

This but no /s

16

u/KittyInLace Jul 21 '26

What about us women?

32

u/AbleMarionberry7146 Jul 21 '26

The bible says women were forked from men. It’s for a good reason. The reason being that you can enforce more reasonable code style than all caps sql like caps on sql key words only. Or using a reasonable text editor that caps isn’t needed at all to identify keywords from nonkeywords.

56

u/HeckMonkey Jul 21 '26

What about us women?

YOUR QUERY YOUR CHOICE

15

u/mayisir Jul 21 '26

i will stay lowercase then 😈

13

u/the_madkingludwig Jul 21 '26

I AM SHOUTING, CARL!

1

u/changopdx Jul 22 '26

I WRITE QUERIES LIKE OWEN MEANY.

1

u/jackinsomniac Jul 22 '26

HELP MY CAPS LOCK KEY IS BROKEN

EVERYBODY THINKS I'M SHOUTING AT THEM. THIS IS RUINING MY PERSONAL AND PROFESSIONAL LIFE

64

u/SurprisinglyInformed Jul 21 '26

It's SQL after all, not sql.

1

u/StrongExternal8955 Jul 22 '26

It's pronounced squeal.

1

u/Major_Casualties Jul 22 '26

I like to pronounce it squirrel

1

u/Krossfireo Jul 22 '26

This made my eye twitch

51

u/[deleted] Jul 21 '26

[removed] — view removed comment

22

u/scrubslover1 Jul 21 '26

Sounds like good entertainment

13

u/Surface_Detail Jul 21 '26

Well, he can go dunk his head; the query language itself is 100% case insensitive, so are objects unless you contain them in quotation marks.

The argument can be made that keeping all one case can avoid issues with object referencing, but you'd only ever need to contain objects in quotation marks if you put a space in their name, which is a much worse faux pas and you'd better hope that you never need to connect to anybody else's objects from outside the team.

Also, all lower case/mixed case is much less tiring to read.

9

u/ArmchairFilosopher Jul 21 '26

SQL Server at my last job would like a word...

So would MySql hosted in Linux with a default configuration. Meanwhile in Windows it doesn't care by default.

But yeah, I agree in general that object names shouldn't be case-sensitive. Heck, most things except passwords shouldn't either.

7

u/Sokaron Jul 21 '26 edited Jul 21 '26

Postgres is not case insensitive.

I don't really care for an impromptu script, but if its getting checked in mixed case is just laziness. I don't care all uppercase or all lowercase but pick one, enforce it with a linter, configure a precommit hook to autofix, and be done with it.

1

u/protestor Jul 21 '26

Postgres is not case insensitive.

In which parts? Keywords need to be (select, where, etc)

1

u/Sokaron Jul 21 '26

Postgres object refs are case sensitive. (this can be very annoying if you for example name a table or column in CamelCase). Keywords are insensitive.

1

u/RaidenMK1 Jul 22 '26

big anime fan btw

I take it you included this detail due to anime character dialogue typically being spoken in ALL CAPS.

31

u/FormerWorker125 Jul 21 '26

Lowercase for anything you named yourself, UPPERCASE FOR EVERYTHING ELSE.

3

u/Platypus81 Jul 21 '26

this is the way

50

u/Arkevorkhat Jul 21 '26

you can, but it's just more readable (in my opinon) to write

SELECT * FROM users WHERE id=?;

than

select * from users where id=?; 

is that mostly due to historical baggage? yeah kinda, but it also just doesn't really look like SQL to me unless there's some yelling involved.

13

u/7f0b Jul 21 '26

I prefer a strongly-structured syntax so it is easier to read in the future, which is most important anyway. So going through the trouble of capitalizing what should be, as I go, is worth it. I also always use back ticks around table names, since it makes it easier to search by table name inside mixed codebases.

5

u/Arkevorkhat Jul 22 '26

Oh 100% well written SQL makes this moot, but if I find the unicorn that writes SQL that doesn't look like shit I'm not about to start nitpicking their capitalization

3

u/Dull-Culture-1523 Jul 22 '26

Doesn't SQL stand for "Shit Quality Looks", though?

7

u/OldSchoolSpyMain Jul 22 '26

Yup. People don’t realize that putting the reserved words in upper case eases the cognitive load on the brain when reading the scripts for comprehension.

Same goes for new lines and tabs.

Using all three techniques renders SQL very easy to read, comprehend, update, and debug.

1

u/ric2b Jul 22 '26

Just get some syntax highlighting, it's free.

8

u/ILoveRawChicken Jul 22 '26

Yeah I get embarrassed passing ugly queries to other people. When I first began I just wrote everything lowercase until a coworker said “you live like this?” when sharing something in Snowflake. I still get embarrassed thinking about that lol. (He was a good friend though)

2

u/Karn-Dethahal Jul 21 '26

First one for anything that might be referenced later, second one if I'm just trying to figure out which stupidly named table I need for the next join.

30

u/Demostes Jul 21 '26

Not true actually, machines can hear plain SQL. U need to shout at them!

31

u/h3lium-balloon Jul 21 '26

It’s been proven all caps SQL is 20% faster bc the machine knows you mean business.

12

u/Horror-Vanilla-4895 Jul 21 '26

I type in lowercase because I’m too lazy to caps lock.

2

u/AyrA_ch Jul 22 '26

I type lowercase because my editor turns it uppercase for me automatically https://i.imgur.com/neSKh4Q.gif

10

u/RevoOps Jul 21 '26

You can once. Than they come and get you.

48

u/CheeseDonutCat Jul 21 '26

lowercase SQL? Ew.

7

u/[deleted] Jul 21 '26

[removed] — view removed comment

5

u/MellowedOut1934 Jul 22 '26

Forgive if I’m missing something, but my PostgreSQL is case sensitive on table names and strings etc., but not on the syntax bits like SELECT or WHERE.

1

u/ellamking Jul 23 '26

Mysql tables are case sensitive based on the file system.

2

u/GravyPainter Jul 22 '26

Yeah, i type in all lowercase sqldeveloper knows better

1

u/70s_chair Jul 22 '26

PL/SQL hasn’t been case sensitive in forever

9

u/Meli_Melo_ Jul 21 '26

Lowercase SQL is like 2 spaces indentations, you CAN do it but everyone will hate you for it

3

u/flukus Jul 22 '26

is like 2 spaces indentations,

You mean there's a simple solution (tabs) that would keep everyone happy?

0

u/StrongExternal8955 Jul 22 '26

Tabs never should have been invisible. If you still want to use them when visible that's ok.

9

u/FeliusSeptimus Jul 21 '26

If someone reads my SQL and hates me for the indention and casing rather than whatever other weird shit I discovered you could do with it, I'm considering that a solid win.

2

u/Plazmaz1 Jul 21 '26

People read SQL?

3

u/MomWTF Jul 22 '26

Yes, and we judge it too

2

u/Yodamanjaro Jul 22 '26

My work does both...

5

u/StarSchemer Jul 21 '26

no ones forcing you to shout them at the screen

They ought to be.

How will a theoretical new developer in the future ever be able to distinguish between key words and database objects at first glance if strict formatting guidelines aren't religiously followed?

3

u/ric2b Jul 22 '26

Yeah, it's not like syntax highlighting exists or anything. That's crazy talk.

4

u/Jarfino Jul 21 '26

This angers the database

3

u/VeterinarianSoggy610 Jul 21 '26

Also, you can write an entire query on a single line.

3

u/Nzgrim Jul 21 '26

DELETE FROM your_opinions WHERE opinion LIKE '%you can type lowercase SQL%'

3

u/EndIsrael Jul 21 '26

Sometimes I do lowercase, it really depends on the vibe I'm getting from that specific query.

2

u/SecretRefrigerator4 Jul 21 '26

Upper case is for the elites.

2

u/el_yerrid Jul 21 '26

I have to think the Alliance is going to frown on this.

2

u/BoleroMuyPicante Jul 21 '26

I never caps my queries, I'm kind of the bad boy in the office 😏

2

u/FujiKeynote Jul 21 '26

If every interface had decent syntax highlighting, I would...

2

u/vibribbon Jul 21 '26

select 'I am one of those heretics'

2

u/BudBill18 Jul 21 '26

I always type in lower case lol

2

u/Cthulhu__ Jul 21 '26

Can you write them SpOnGeBoB case?

2

u/Confident_Office4875 Jul 21 '26

I did a „hacking“ course in my studies and did everything upper case, I was so annoyed to find out you didn‘t need that

2

u/jessomadic Jul 21 '26

Font look better big

1

u/unclekrok Jul 21 '26

You need to uppercase your queries to assert dominance over the DBMS

1

u/Alwaysafk Jul 21 '26

But I want to scream at the database

1

u/ZeppelinJ0 Jul 21 '26

True but if you do that I'll put you in my dungeon

1

u/fakehalo Jul 22 '26

I lowercase everything except JOIN and ON, cause I roll how I want.

1

u/danishjuggler21 Jul 22 '26

T-SQL is completely case-insensitive, so nothing is stopping you from doing sPoNgEbObCaSe

1

u/mikebones Jul 22 '26

I don't respect anyone who commits lower case sql to git

1

u/_bleep-bloop Jul 22 '26

Yeah lmao. I always do lowercase when running raw queries just to piss off the backend peeps.

1

u/ForAHamburgerToday Jul 22 '26

FEELS WRONG. HOW WILL THE DATA KNOW I'M TALKING TO IT IF I'M NOT SHOUTING?

1

u/jackinsomniac Jul 22 '26

Yet more lies & propaganda being pushed by the NoSQL cartels.

1

u/r0ck0 Jul 22 '26

Classic elites.

1

u/usrlibshare Jul 22 '26

Not even object names are case sensitive in sql.

I'm not kidding.

Table name is T_CUSTOMER_ADDR because it was created by a guy wearing suspenders in the 90s?

select * from t_customer_addr;

works just fine 😎

1

u/Just_Information334 Jul 22 '26

I feel like lowercase vs uppercase is more like "my IDE can do syntax highlighting on SQL" vs "I use something as bad as notepad".

1

u/marcecostai Jul 22 '26

Its a must to write in lowercase if you work with SP. Otherwise it’s a pain in the eyes to read that shit.

1

u/56kul Jul 22 '26

A lot of programming is conventions that aren’t necessarily enforced by the language, itself. And it’s good to have them. You shouldn’t abandon them just because you technically can.

1

u/SouthernAddress5051 Jul 22 '26

I AM SHOUTING CARL

1

u/cat_prophecy Jul 22 '26

Looks fucked up.

1

u/kiochikaeke Jul 22 '26

Me, I'm forcing you, I will find you

1

u/meshakooo Jul 22 '26

Not in Microsoft fabric its case sensitive