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
0 件のコメント: