Mysql search text in one column -
Mysql search text in one column -
for illustration our table;
İd--------price---------level 1 ------100-300 ------ 1,2 2 ---------200----------1 3 ------100-280--------1,3
we want search cost value 110. 110 between 100-300 , 100-280 id 1 , id 2 must listed. can write query my-sql?.
additional , want search cost , level value. cost 110 , level 2 searching. can write query my-sql?.
thank
remember database tables should created thought satisfy query needs. doesn't create sense have table cost "100-300" represents string (or in mysql varchar) , want treat number. do?
1) first thing re write table schema having minprice , maxprice fields, way have this:
İd----minprice---maxprice------level 1 ------100---------300 ------ 1,2 2 ------200---------200----------1 3 ------100---------280--------1,3
2) query like:
select id mytable x myvalue >= x.minprice , myvalue <= x.maxprice
3) in case want level value. do:
select id mytable x myvalue >= x.minprice , myvalue <= x.maxprice , mylevelvalue in (x.level)
mysql search text
Comments
Post a Comment