我试图从同一个表中选择两个数据集,而不是做两个查询,我试图在一次调用中同时选择它们。
首先,我想:
SELECT COUNT(*) AS `total` FROM `Messages` WHERE `id` = '1';
第二个是:
SELECT COUNT(*) AS `total_read` FROM `Messages` WHERE `id` = '1' AND `read` = '1';
无论如何可以在一个查询中执行此操作吗?
我试图从同一个表中选择两个数据集,而不是做两个查询,我试图在一次调用中同时选择它们。
首先,我想:
SELECT COUNT(*) AS `total` FROM `Messages` WHERE `id` = '1';
第二个是:
SELECT COUNT(*) AS `total_read` FROM `Messages` WHERE `id` = '1' AND `read` = '1';
无论如何可以在一个查询中执行此操作吗?