mysql - 如何识别mysql中相同列中具有相同值的行?而且我还必须为这些行添加条件
问题描述
id bid status time
1 c1 close 2019.10.11
2 c2 close 2019.12.12
3 c2 open 2019.12.11
4 c3 close 2019.12.14
在这里我想同时捕获 c2 并且我必须找到时间差
解决方案
您可以使用exists
select t.*
from t
where exists (select 1 from t t1 where t1.bid = t.bid and t1.time <> t.time);
推荐阅读
- rust - 如何将切片写入文件?
- netlogo - 如何将列表(和其他信息)从父模型全局变量传递到 Netlogo 的 LevelSpace 中的子模型全局变量
- c++ - C++。std::condition_variable 和多个等待线程
- python - 从哪里可以得到pytorch torchvison 中模型的所有方法的详细描述?
- c - C程序在分配变量时停止执行
- javascript - 一个类中具有来自同一变量的值的两个或多个属性是相关的
- java - 如何为图像存储指定外部位置
- c# - Fluent Validation Entity 添加操作验证问题
- mysql - 使用csv文件到mysql
- javascript - React JS 设置状态仅适用于上一项