开发者

problem with searching a sting containing some Letters using mysql query

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜