开发者

problem with searching a sting containing some Letters using mysql query

开发者 https://www.devze.com 2023-03-14 16:28 出处:网络
i want to search a column data contain some letters like OP or OPS. desp -------- 9037OP 3HTVO开发者_StackOverflowPS

i want to search a column data contain some letters like OP or OPS.

desp
--------
 9037OP

 3HTVO开发者_StackOverflowPS

 G4OP568H

select * from table WHERE desp LIKE '%OP' OR '%OPS' order by desp desc

if try this query its returned only '9037OP'


I think the correct query should be

This is when OP and OPS shoule be found only at the end of the string

select * from table `desp` WHERE `desp` LIKE '%OP' OR `desp` LIKE '%OPS' order by `desp` desc

and for OP, OPS anywhere in the string

select * from table `desp` WHERE `desp` LIKE '%OP%' OR `desp` LIKE '%OPS%' order by `desp` desc
0

精彩评论

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

关注公众号