开发者

Mysql query - how to force sign "_" in pattern matching?

I have in database TEST these values for example:

ID
1_0    
1_1
10_1
11_1

If I want select all values ​​at the beginning with number "1", but not "10" or "11" then I have created my request in that way:

SELECT * F开发者_开发知识库ROM test WHERE id LIKE '1_%';

But sign _ for Mysql Query also means one character from name so result of this will be all the values from the list.

My question is - how to force query to think that _ is a character in ID name, not sign of any letter?


I think you should be able to just escape the _ like so:

SELECT * FROM test WHERE id LIKE '1\_%';
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜