select * from product where concat(',',price,',') regexp '(,([1-7]{1}){0,1}[0-9]{1},)|,80,';
这个本人测试过是可行的,楼主有测试过吗?[/quote][/quote]
是的,用正则不好。所以我先提出的方案是加一个表,不过看楼主应该是纠结在不改动数据表结构上。
应该建立多一个产品价格表 product_price
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,';