this post was submitted on 19 Oct 2023
1697 points (98.8% liked)

Programmer Humor

32495 readers
259 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 17 points 1 year ago* (last edited 1 year ago) (5 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 (3 children)

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

[–] callcc@lemmy.world 5 points 1 year ago (1 children)

Actually not. It's part of the FROM

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

That double indented from is hurting me

load more comments (1 replies)
load more comments (2 replies)