You are viewing a single thread.
View all comments View context
18 points
*

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.

permalink
report
parent
reply
14 points

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

permalink
report
parent
reply
8 points

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
permalink
report
parent
reply
6 points

Actually not. It’s part of the FROM

permalink
report
parent
reply
2 points

That double indented from is hurting me

permalink
report
parent
reply
1 point

Um you forgot the semicolon before with assuming there isn’t one in the previous statement. Syntax error. Code review failed

permalink
report
parent
reply
5 points

There’s no way we’re running in multi statement mode… I like my prepared queries, thank you very much.

permalink
report
parent
reply
1 point
*
Deleted by creator
permalink
report
parent
reply

Programmer Humor

!programmerhumor@lemmy.ml

Create post

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

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.

Community stats

  • 4.1K

    Monthly active users

  • 1.5K

    Posts

  • 35K

    Comments