Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试通过MySQL单个查询获取三个不同表中的简单行数。这是我所拥有的:
MySQL
SELECT count(s.`id`) AS c1, count(g.`id`) AS c2, count(r.`id`) AS c3 FROM table1 s, table2 g, table3 r
但这不起作用,我认为它将所有三个总数相乘。谢谢您的帮助。
如果表没有关系并且无法连接,请尝试以下操作:
SELECT (select count(id) from table1) as c1, (select count(id) from table2) as c2, (select count(id) from table3) as c3