标题: mysql5.5查询问题 [打印本页] 作者: 无敌风火轮 时间: 2012-12-21 10:19 标题: mysql5.5查询问题 在mysql5.5中查询表test,file_path字段保存文件路径信息如c:\test
使用查询语句"select * from test where file_path like '%c:\test%'"结果为空
使用查询语句"select * from test where file_path like '%\test%'"结果正常
请教高手解决之道作者: squall 时间: 2012-12-21 15:21
在字符串中,某些序列具有特殊含义。这些序列均用反斜线(‘\’)开始,即所谓的转义字符。MySQL识别下面的转义序列: http://dev.mysql.com/doc/refman/5.1/zh/language-structure.html作者: squall 时间: 2012-12-21 15:43
mysql> select * from t;
+------+------+----------+
| a | b | c |
+------+------+----------+
| 1 | 2 | c:\test1 |
| 1 | 3 | c:\test2 |
| 2 | 4 | c:\test |
+------+------+----------+
3 rows in set (0.03 sec)
mysql> SELECT * FROM t WHERE c LIKE 'c:\\\\test';
+------+------+---------+
| a | b | c |
+------+------+---------+
| 2 | 4 | c:\test |
+------+------+---------+
1 row in set (0.03 sec)
mysql> SELECT * FROM t WHERE c LIKE 'c:\\\\test%';