I have a table with columns, itemid, itemname, price1, price2, price3, price4, price5, price6, price7, etc. These are different prices from different distributors. I am displaying these records in a table thru php. What I want is , get 3 lowest distributor prices. Forexample, item1 -> lowest from price1, price2,price3, price4..... second lowest from price1, price2, price3, price4.... third lowest from price1, price2, price3, price4.... Can anyone give an idea ?
The constructions of the tables are "wrong" - what you should have is two tables, one for itemid, itemname and a second for prices with id, itemid and price and then have several entries in this for each item. That way you will get something like SELECT t1.*,t2.* FROM items t1 LEFT JOIN itemprices t2 ON t1.itemid = t2.itemid ORDER BY price
i cannot change the table structure now as it is coming from a scraper. I have one item and multiple price columns. with this structure is it possible to get lowest prices across columns for each row ??
thanks. I think this might work, I will try it out. I have never used this function so will try it out.