我想[listings]
根据相同的用户 ID 值从 [ads] 表中选择标题列和列表出现的次数。
结果应如下所示:
[title] [cnt]
Acme 5
MSFT 10
GOOG 7
ETC
这不起作用:
select
l.title,
(COUNT (id) FROM ads WHERE ads.userid = l.userid) as cnt
from
listings l
INNER JOIN
ads a on a.userid = l.userid
WHERE
l.listingtype = 2