如何用SQL语句查找出varchar字段中以“URL查询字符串”(例如20=5&30=10)格式存放的数据 本帖最后由 lscxp 于 2011-03-18 15:47:11 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 SELECT * FROM TT WHERE INSTR(`text`,CONCAT('aaaa','='))>0 select * from 比如有一个表where `text` regexp '(^|&)2='; mysql> select * from t_lscxp;+------+-------------+| id | text |+------+-------------+| 1 | 1=1 || 2 | 2=10&10=3 || 3 | 5=5&3=6 || 4 | aaa=123 || 5 | bbb=23 || 6 | 2=7&3=100 || 7 | 22=7&3=100 || 8 | 22=7&2=100 || 9 | 22=7&22=100 |+------+-------------+9 rows in set (0.02 sec)mysql> select * -> from t_lscxp -> where `text` regexp '(^|&)2=';+------+------------+| id | text |+------+------------+| 2 | 2=10&10=3 || 6 | 2=7&3=100 || 8 | 22=7&2=100 |+------+------------+3 rows in set (0.00 sec)mysql> select * -> from t_lscxp -> where `text` regexp '(^|&)3=';+------+------------+| id | text |+------+------------+| 3 | 5=5&3=6 || 6 | 2=7&3=100 || 7 | 22=7&3=100 |+------+------------+3 rows in set (0.00 sec)mysql> select * -> from t_lscxp -> where `text` regexp '(^|&)aaa=';+------+---------+| id | text |+------+---------+| 4 | aaa=123 |+------+---------+1 row in set (0.00 sec)mysql> 小白求帮忙,想做一个东西但是不知道应该学习什么? LIKE where判断数字的字段该如何写? 请问这个报纸单价表如何设计 Mysqld安全相关启动选项--safe-user-create 关于MySQL的几个问题 linux as4 +php5.2.0+mysql5.0.27 phpinfo未显示mysql信息 用HEIDISQL创建触发器有问题 mysql存储二进制问题. mysql数据库多表查询 MYSQL 主从同步某一个指定库,有一个表死活不同步?为什么,其他表正常! 多个mysql query 并列,如何检索结果不重复? 跪求SQL
from 比如有一个表
where `text` regexp '(^|&)2=';
+------+-------------+
| id | text |
+------+-------------+
| 1 | 1=1 |
| 2 | 2=10&10=3 |
| 3 | 5=5&3=6 |
| 4 | aaa=123 |
| 5 | bbb=23 |
| 6 | 2=7&3=100 |
| 7 | 22=7&3=100 |
| 8 | 22=7&2=100 |
| 9 | 22=7&22=100 |
+------+-------------+
9 rows in set (0.02 sec)mysql> select *
-> from t_lscxp
-> where `text` regexp '(^|&)2=';
+------+------------+
| id | text |
+------+------------+
| 2 | 2=10&10=3 |
| 6 | 2=7&3=100 |
| 8 | 22=7&2=100 |
+------+------------+
3 rows in set (0.00 sec)mysql> select *
-> from t_lscxp
-> where `text` regexp '(^|&)3=';
+------+------------+
| id | text |
+------+------------+
| 3 | 5=5&3=6 |
| 6 | 2=7&3=100 |
| 7 | 22=7&3=100 |
+------+------------+
3 rows in set (0.00 sec)mysql> select *
-> from t_lscxp
-> where `text` regexp '(^|&)aaa=';
+------+---------+
| id | text |
+------+---------+
| 4 | aaa=123 |
+------+---------+
1 row in set (0.00 sec)mysql>