0

使用 Mysql 我如何将这两个命令合并为一个?

select id from User where name='name'
select count(*) from Msg where user_id=@id
4

1 回答 1

3

您可以加入表格:

SELECT COUNT(*)
FROM User a
INNER JOIN Msg b ON a.id = b.user_id
WHERE a.name = 'name'
于 2012-07-14T22:06:30.010 回答