简体   繁体   中英

mysql where in from field multiple value

I have table region with fields

id | name | dates

Sample data

1 | local | "2018-01-01", "2018-01-02", "2018-01-03"

I want a query like this

SELECT * FROM region WHERE "2018-01-02" in (region.dates) 

but this does not work. I do not use json data in this case. How can I change it?

(My)SQL doesn't work like that as it will see region.dates as a simple string. In which case, you can do SELECT * FROM region WHERE dates LIKE '%"2018-01-02"%';

However, a better solution would be to devolve that column into another table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM