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 table Posts
where the field Posts.thread
is the same as Threads.id
.
How can this be done in SQL?
(Something like this pseudo-SQL: SELECT *, COUNT(* FROM Posts WHERE Posts.id=Threads.id) FROM Threads
)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…