mysql有表A:id num
1 4
2 9
3 14
4 20
5 25
表B:id start end
1 0 5
2 6 10
3 11 15怎么能查询到存在于表B中任一的start字段和end字段之间的数?比如 表A中的4,9,14都是在表b两个字段之间的数,而20和25因为没有在表b任一字段之间所以无法查询出来..
1 4
2 9
3 14
4 20
5 25
表B:id start end
1 0 5
2 6 10
3 11 15怎么能查询到存在于表B中任一的start字段和end字段之间的数?比如 表A中的4,9,14都是在表b两个字段之间的数,而20和25因为没有在表b任一字段之间所以无法查询出来..
解决方案 »
- mysql获取数据,报“值对于Int32太大或太小”错误
- 缺少更新或刷新的键列信息
- 急!使用auto_increment产生间隙!
- sum求和的语句,sum()在where中?
- 查询问题,如何计算相应记录所占的百分比?
- SOS!毕业设计,要求给MySQL 数据库做出个浏览器界面,请牛人指教,小弟在此多谢了
- mysql 修改栏位失败
- mysql中是否有类似于oracle中for update nowait的替代语句。
- 求助 求助 MySQL 不能创建函数 在Godaddy 虚拟空间上
- 如何通过程序实现mysql通过dblink与erp的oracle建立连接
- 求个SQL语句
- 急,急,急,用ExecuteNonQuery运行load data infile 总是报错!想了很久都想不出来!
on a.num between b.start and b.enf
+----+------+
| id | num |
+----+------+
| 1 | 4 |
| 2 | 9 |
| 3 | 14 |
| 4 | 20 |
| 5 | 25 |
+----+------+
5 rows in set (0.00 sec)mysql> select * from b;
+----+-------+------+
| id | start | end |
+----+-------+------+
| 1 | 0 | 5 |
| 2 | 6 | 10 |
| 3 | 11 | 15 |
+----+-------+------+
3 rows in set (0.00 sec)mysql> select a.id,num from a,b where a.id=b.id and a.num between b
-> .start and b.end;
+----+------+
| id | num |
+----+------+
| 1 | 4 |
| 2 | 9 |
| 3 | 14 |
+----+------+
3 rows in set (0.02 sec)
from a inner jon b on a.num between b.start and b.end
select * from a
where exists (select 1 from b where a.num between b.start and b.end)
你好,问下MySql5.1的MyISAM引擎数据库支持子查询吗?
我前几天写了个报错。