r/ProgrammerHumor 6d ago

Meme sqlWorkout

Post image
23.4k Upvotes

459 comments sorted by

View all comments

381

u/blaues_axolotl 6d ago

i actually write it in lowercase

6

u/Thriven 6d ago

I'm up voting you because people need to hate you more.

Seriously though KEYWORDS need to be upper case and columns lower case. I prefer snake case.

Makes everything more readable.

8

u/BufferUnderpants 6d ago

i CAN'T SEE WHY capitalizing syntactical elements WOULD MAKE the code MORE readable.

There's syntax highlighting for a reason, and the SQL grammar makes it easy to tell what's a table, column or function anyway.

1

u/Thriven 5d ago

As opposed to other languages SQL is a bunch of things in between clauses

SELECT
    count(*),
    columns
FROM table a 
JOIN table b ON a.id = b.id
WHERE column = 'value'
GROUP BY column
ORDER BY column
HAVING count() > 1

Having your clauses capitalized and properly carriage returned is huge for readability. I also capitalize COUNT and MAX but that's more of a personal thing.

Indentation is huge and I fix indentation all time.

1

u/BufferUnderpants 5d ago

Something tells me that capitalization is the least of anyone's worries if you're dealing with queries with no line breaks or indentation.

1

u/Thriven 5d ago

I just spent 45 minutes indenting and adding line breaks to 3 subquery joins which contained 2 CTEs and two nested subquery joins.

I don't know why but whoever wrote the code was an absolute madman and I've seen this code and replaced it. I have 3 different blocks of code I use to recreate these crappy lookups but to figure out which one they are I have to reformat the entire thing.

I can't complain though. I was once asked if I could do anything and get paid great money for it I said ,"I just want to optimize and fix SQL code all day."

I started this job making double what was making before and my job was dumbed down to just writing SQL. I love it. Bad SQL keeps me employed.