如何使用一次查询获取数据库上的总行数

15 浏览
0 Comments

如何使用一次查询获取数据库上的总行数

我有一个包含两个表的数据库,我想使用一个查询来获取这些表的行总数。

SELECT (count(bill.*) + count(items.*)) as TTL FROM bill, items // Failed 
SELECT count(*) as TTL FROM bill, items // wrong total
SELECT (count(bill.ID_B) + count(items.ID_I)) as TTL FROM bill, items // wrong total
SELECT count(bill.ID_B + items.ID_I) as TTL FROM bill, items // return the biggest total

admin 更改状态以发布 2023年5月22日
0
0 Comments

使用两个子查询:

select (select count(1) from bill) + (select count(1) from items);

0