Isolate values based on format in mysql
I have a date column that is really messed up.
It had %m/%d/%y values that I have reformatted to %Y-%m-%d like they should be.
Now I am discovering that there are records that have a date in them that are %d%y%m!!
Now I need to only select those values that look like 000000 and nothing that is 0000-00-00 o开发者_如何学Gor 0000/00/00.
What is the best way to isolate that format?
Thanks
You should use the date column types to avoid such issues. This also allows you to use the mysql date and time functions
To solve your issue you can use select * from mytable where mydate not like '____-%__%__' and not like '____/__/__'
(note the number of underscores).
If this is not enough for you, use a mysql regular expression.
精彩评论