作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有两个表,它们应该在 mId 和 keyValue 列中存储相同的值。但是我运行以下命令并得到以下结果:
mysql> select count(distinct mId) from Types;
+---------------------+
| count(distinct mId) |
+---------------------+
| 2098350 |
+---------------------+
select count(distinct keyValue) from EntityIndex;
+--------------------------+
| count(distinct keyValue) |
+--------------------------+
| 2095481 |
+--------------------------+
找到Type表中刚好存在的mId。我运行以下命令并得到以下结果:
mysql> select distinct mId from Types where not exists
(select distinct keyValue from EntityIndex);
Empty set (0.00 sec)
mysql> select distinct keyValue from EntityIndex where not exists
(select distinct mId from Types);
Empty set (0.01 sec)
问题是什么?
最佳答案
我认为你可以通过这种方式找到缺失值
select a.mId, b.keyValue
from Types as a
left join EntityIndex as b on a.mId = b.KeyValue
where b.kvalue is null
你也可以试试不在
select distinct mId from Types where mId not in
(select distinct keyValue from EntityIndex);
关于mysql - 如何在MySQL中查找其他列中不存在的列的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35902504/
我是一名优秀的程序员,十分优秀!