假设我有四个个表,我只需选择3个表,其数据库名为Records
Records
1.Cases
2.Ballistics
3.Chem
4.Accounts
Cases
id|year|Natureofcase |
0 | |Repact 1901a |
1 |2003|Repact 1907b |
3 |2004|Repact 1902 |
Ballistics
id|year|Name |Type |
0 |2003| |a-101 |
1 | |Silver-A |a-202 |
3 |2005|Red Cap | |
Chem
id|year|Identified |
0 | |H20+C20 |
1 |2001|Am |
3 |2009| |
所以我们有 6 行包含空表。 我想使用 PHP 显示总和 6。谢谢。任何意见/答案/建议将不胜感激。
最佳答案
请尝试一下
SELECT
(SELECT COUNT(*) FROM Cases WHERE year = '' OR Natureofcase = '') +
(SELECT COUNT(*) FROM Ballistics WHERE year ='' OR Name='' OR Type='') +
(SELECT COUNT(*) FROM Chem WHERE year='' OR Identified='')
AS total_empty
关于php - 如何计算所选表中具有空字段的所有记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36830847/