- London
- Karachi
- New York ...
- 1,2,3
2,3
3,4
how to write query to find the all cities having city_type
like 3?
SELECT* FROM [your_table] WHERE city_type LIKE '%3%'
Use FIND_IN_SET
select * from [your_table] where FIND_IN_SET(city_type,'3') > 0
Note : Storing more than one value in single column separated by comma is bad way to store information. Consider changing your table structure. Have a separate table for CITY_TYPE
and map it with your table for each CITY
in separate rows
只需在开始和结束时使用带有通配符的LIKE
,就像这样
SELECT * FROM TABLE_NAME WHERE city_type LIKE '%3%';
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.