MYSQL查询某个范围的数据 本帖最后由 ww2128228 于 2011-07-24 10:27:31 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 SELECT * FROM t2 order by abs(value-字段A) select * from 一张表 where 给定一个值 between 最小值 and 最大值 这里的常量8是你传入的参数值:mysql> use test;Database changedmysql> create table tb_test(maxValue int,minValue int,otherCol varchar(10));Query OK, 0 rows affected (0.04 sec)mysql> insert into tb_test -> select 5,2,'A' -> union all -> select 10,7,'B';Query OK, 2 rows affected (0.00 sec)Records: 2 Duplicates: 0 Warnings: 0mysql> select * from tb_test where minValue<=8 and maxValue>=8;+----------+----------+----------+| maxValue | minValue | otherCol |+----------+----------+----------+| 10 | 7 | B |+----------+----------+----------+1 row in set (0.00 sec) 请教MYSQL 查询数据手工改后批量更新. mysql中如何备份information_schema数据库 Mysql insert多条记录的问题 存储过程中游标内为什么无法使用变量设值呢 附代码 mysql 触发器删除 字符串的比较 一个关于数据库高速缓冲的设想,Linux下如何实现? 统计3月1日之前注册,4月1日前有过1到3个订单 mysql 指定查询分区问题、 求助:xtrabackup 2.4.2 备份mysq-5.7 Navicat可以连接mysql,ecshop却不行 MySQL 中文显示一半
mysql> use test;
Database changed
mysql> create table tb_test(maxValue int,minValue int,otherCol varchar(10));
Query OK, 0 rows affected (0.04 sec)mysql> insert into tb_test
-> select 5,2,'A'
-> union all
-> select 10,7,'B';
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0mysql> select * from tb_test where minValue<=8 and maxValue>=8;
+----------+----------+----------+
| maxValue | minValue | otherCol |
+----------+----------+----------+
| 10 | 7 | B |
+----------+----------+----------+
1 row in set (0.00 sec)