this post was submitted on 19 Oct 2023
1613 points (98.7% liked)

Programmer Humor

32429 readers
722 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] xmunk@sh.itjust.works 169 points 1 year ago (52 children)

Speaking as a Senior Dev specialized in database access and design... you don't have to use all caps - SQL is actually case agnostic.

But... but my fucking eyes man. I'm old, if your branch doesn't have control keywords in all caps I'm going to take it out back and ol' yeller it.

There are few hills I'll die on but all caps SQL and singular table names are two of them.

[–] Nolegjoe@lemmy.world 67 points 1 year ago (35 children)

I'm a sql developer, and I am completely the opposite to you. I will find it incredibly difficult to read when everything is in caps

[–] xmunk@sh.itjust.works 16 points 1 year ago* (last edited 1 year ago) (7 children)

Sorry, to clarify, not everything is in all caps. I'll append my prefered syntax below

WITH foo AS (
    SELECT id, baz.binid
    FROM
            bar
        JOIN baz
            ON bar.id = baz.barid
)
SELECT bin.name, bin.id AS binid
FROM
        foo
    JOIN bin
        foo.binid = bin.id

The above is some dirt simple SQL, when you get into report construction things get very complicated and it pays off to make sure the simple stuff is expressive.

[–] NedDasty@lemmy.world 12 points 1 year ago (2 children)

You indent your JOIN? Why on earth? It lives in the same context as the SELECT.

[–] xmunk@sh.itjust.works 8 points 1 year ago

I've seen both approaches and I think they're both quite reasonable. An indented join is my preference since it makes sub queries more logically indented... but our coding standards allow either approach. We've even got a few people that like

FROM foo
JOIN bar ON foo.id = bar.fooid
JOIN baz ON bar.id = baz.barid
[–] callcc@lemmy.world 3 points 1 year ago (1 children)

Actually not. It's part of the FROM

[–] Stumblinbear@pawb.social 1 points 1 year ago

That double indented from is hurting me

load more comments (4 replies)
load more comments (31 replies)
load more comments (47 replies)