再次请教各位高人,这条语句又该如何简化
SELECT name,
(SELECT COUNT(id)
FROM class
WHERE f_grade_id = 1 AND type = dbo.basicmess.id) AS todal
FROM dbo.basicmess
WHERE (type = 1)
[解决办法]
try
SELECT A.name,
COUNT(B.id) AS todal
FROM dbo.basicmess A
Left Join class B
On B.f_grade_id = 1 AND B.type = A.id
WHERE (A.type = 1)