I have a table (Threads) containing a field (id). I would like to select every row from Threads, as well as the number of rows in the
Threads
id
SELECT t.id, COUNT(p.thread) FROM Threads AS t LEFT OUTER JOIN Posts AS p ON t.id = p.thread GROUP BY t.id
Sure - something like this?
SELECT t.ThreadID, (SELECT COUNT(*) FROM dbo.Posts p WHERE p.ThreadID = t.ThreadID) FROM dbo.Threads t