近年まれに見るどうでもよさ

2018/03/13

投げっぱなし

みんなラブワイフ弁当かよ!<何が ごきげんよう。

SQL書くときのJOINとかONのインデントの自分ルールがなかなか
定まらなくてですね。(どうでもいいよ)
最近の書き方だけでも3通りもあります。

FROM
    entries
    LEFT OUTER JOIN comments ON
        entries.blog_id = comments.blog_id
        AND entries.entry_id = comments.entry_id

FROM
    entries
    LEFT OUTER JOIN comments
        ON entries.blog_id = comments.blog_id
        AND entries.entry_id = comments.entry_id

FROM
    entries
    LEFT OUTER JOIN comments
        ON
            entries.blog_id = comments.blog_id
            AND entries.entry_id = comments.entry_id

さらにJOIN句がサブクエリだったりするともう収拾つきません…。



FROM
    entries
    LEFT OUTER JOIN (
        SELECT
            ...
        FROM
            comments
        WHERE
            ...
    ) AS c ON
        entries.blog_id = c.blog_id
        AND entries.entry_id = c.entry_id

FROM
    entries
    LEFT OUTER JOIN (
        SELECT
            ...
        FROM
            comments
        WHERE
            ...
    ) AS c
        ON
            entries.blog_id = c.blog_id
            AND entries.entry_id = c.entry_id

FROM
    entries
    LEFT OUTER JOIN
        (
            SELECT
                ...
            FROM
                comments
            WHERE
                ...
        ) AS c ON
            entries.blog_id = c.blog_id
            AND entries.entry_id = c.entry_id

FROM
    entries
    LEFT OUTER JOIN
        (
            SELECT
                ...
            FROM
                comments
            WHERE
                ...
        ) AS c
        ON
            entries.blog_id = c.blog_id
            AND entries.entry_id = c.entry_id

ソーシャル/購読

X Threads note
RSS Feedly Inoreader

このブログを検索

ブログ アーカイブ