サブクエリ(副クエリ)とLEFT JOIN(レフト ジョイン)のSQLサンプル

SELECT table1.*, count.count FROM table1 LEFT JOIN
 (SELECT table1_id, count(table1_id) FROM table2 WHERE 条件 GROUP BY table2.table1_id) as count
ON table1.id = count.table1_id WHERE 条件 ORDER BY 条件 OFFSET 条件 LIMIT 条件





関連 2012-02-09 17:59:45