给个思路:
建一个保存所有可能出现的价格的表
查询用 find_in_set 连接
select * from products, 价格表 where find_in_set(价格表.价格, products.price) and 价格表.价格<=80
建一个保存所有可能出现的价格的表
查询用 find_in_set 连接
select * from products, 价格表 where find_in_set(价格表.价格, products.price) and 价格表.价格<=80
id
product_id
price例如产品Ad的price是60,75,80
那么在product_price中就有三条记录
id product_id price
1 1 60
2 1 75
3 1 80
然后
select * from product where id in(select product_id from product_price where price<=80);如果不改动数据表结构
select * from product where concat(',',price,',') regexp '(,([1-7]{1}){0,1}[0-9]{1},)|,80,';
select * from product where concat(',',price,',') regexp '(,([1-7]{1}){0,1}[0-9]{1},)|,80,';这个本人测试过是可行的,楼主有测试过吗?
那么正则规则串由谁来产生呢?
总不能手工去修改吧?
select * from product where concat(',',price,',') regexp '(,([1-7]{1}){0,1}[0-9]{1},)|,80,';这个本人测试过是可行的,楼主有测试过吗?
select * from product where concat(',',price,',') regexp '(,([1-7]{1}){0,1}[0-9]{1},)|,80,';这个本人测试过是可行的,楼主有测试过吗?是的,用正则不好。所以我先提出的方案是加一个表,不过看楼主应该是纠结在不改动数据表结构上。