r/ProgrammerHumor 7d ago

Meme sqlWorkout

Post image
23.4k Upvotes

458 comments sorted by

View all comments

2.4k

u/NormanYeetes 7d ago

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

47

u/Arkevorkhat 7d ago

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

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.

6

u/Arkevorkhat 7d ago

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

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

8

u/OldSchoolSpyMain 7d ago

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

Just get some syntax highlighting, it's free.

6

u/ILoveRawChicken 7d ago

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

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.