开发者

skip characters in like clause of mysql

开发者 https://www.devze.com 2023-03-16 17:55 出处:网络
hello I want to skip some character while matching any string using like using mysql. For example I have a string like this 2011-07-12 06:09. I want to match the only month part of the time stamp not

hello I want to skip some character while matching any string using like using mysql. For example I have a string like this 2011-07-12 06:09. I want to match the only month part of the time stamp not whole. I kn开发者_Go百科ow I can use % for whole string. I want to skip characters from front and end of that part. Would any body tell me how to accomplish this job


Use the MONTH() function for grabbing the month from a date. Don't re-invent the wheel.

If you're really interested in matching a string using like, you'd be better off using the underscore (_) as a the wildcard:

select *
from some_table
where some_column like '__-07-__ __:__'
0

精彩评论

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