这是我的观点,它给出了如上所述的输出:
CREATE
ALGORITHM=UNDEFINED
DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW new_view AS
SELECT 'pcount' AS ind_type,
SUM(pcount) AS Index_val
FROM temp
UNION
SELECT 'ncount',
SUM(ncount)
FROM temp
;
结果:
+----------+------------+ | ind_type | 索引值 | +----------+------------+ | 个数 | 76 | | ncount | 第434章 +----------+------------+
现在我创建了另一个键,pcount
它ncount
使用MAX()
CREATE
ALGORITHM=UNDEFINED
DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW view_name AS
SELECT pcount,
ncount
FROM temp
WHERE id = (SELECT MAX(id) FROM temp)
;
给出结果:
+--------+--------+ | 个数 | ncount | +--------+--------+ | 56 | 56 | +--------+--------+
这个结果怎么可以看成上面的呢?
结果根据斯蒂芬的回答:
+----------+-----------+
| ind_type | Index_val |
+----------+-----------+
| 0 | 0 |
+----------+-----------+
1 row in set (0.01 sec)