我有一个包含字符串的列:
aaa_1
aaa_11
Run Code Online (Sandbox Code Playgroud)
我需要查询以_1.结尾的字符串.我尝试了以下内容:从col中选择col col %_1; 但是查询给了我以_1和结尾的字符串_11.我怎么能纠正这个?
fth*_*lla 26
试试这个:
select col from table where col like '%\_1'
Run Code Online (Sandbox Code Playgroud)
字符_是一个快乐的,像%,但它只匹配一个字符,所以你必须逃避它\
请看:http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html#operator_like
Ada*_*man 11
你会想要使用更多子串相关的东西.
尝试一下where子句,如:
SELECT col from table WHERE RIGHT(col, 2) = '_1'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
28644 次 |
| 最近记录: |