Sử dụng:
SELECT t1.*,
COALESCE(x.num_rows, 0) AS entries
FROM `table 1` t1
LEFT JOIN (SELECT t3.v_id,
COUNT(*) 'num_rows'
FROM `table_3` t3
GROUP BY t3.v_id) x ON x.v_id = t1.v_id
Sử dụng:
SELECT t1.*,
COALESCE(x.num_rows, 0) AS entries
FROM `table 1` t1
LEFT JOIN (SELECT t3.v_id,
COUNT(*) 'num_rows'
FROM `table_3` t3
GROUP BY t3.v_id) x ON x.v_id = t1.v_id