2 gly20031015 gly20031015 于 2013.08.22 15:09 提问

ORACLE: 含通配符的模糊查询

SELECT count(*)
FROM MSG_SEND
WHERE STATUS = '1'
AND SEND_ID = '210000000004843'
AND CONTENT like '%_%'
AND SEND_TIME >= to_date('2013-08-02 00:00:00','YYYY-MM-DD HH24:Mi:SS')
AND SEND_TIME <= to_date('2013-08-22 23:59:59','YYYY-MM-DD HH24:Mi:SS')
escape '\'
执行上面语句的时候会报“命令未正确结束“这种错误

而下面的语句可以正常执行
SELECT count(*)
FROM MSG_SEND
WHERE STATUS = '1'
AND SEND_ID = '210000000004843'
AND SEND_TIME >= to_date('2013-08-02 00:00:00','YYYY-MM-DD HH24:Mi:SS')
AND SEND_TIME <= to_date('2013-08-22 23:59:59','YYYY-MM-DD HH24:Mi:SS')

1个回答

zhuhl2011
zhuhl2011   2013.08.22 18:01

SELECT count(*)
FROM MSG_SEND
WHERE STATUS = '1'
AND SEND_ID = '210000000004843'
AND CONTENT like '%_%' escape '\'
AND SEND_TIME >= to_date('2013-08-02 00:00:00','YYYY-MM-DD HH24:Mi:SS')
AND SEND_TIME <= to_date('2013-08-22 23:59:59','YYYY-MM-DD HH24:Mi:SS')

你escape用错地方了,要跟在like语句后面的

gly20031015
gly20031015 后来我也发现了这个问题,但是通配符问号还是不能正确查询
4 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!