i'm comparing prices of products 3
different website. have 3
different prices. if website doesn't offer product, price empty.
mysql looks this:
**id | name | price_1 | price_2 | price 3**
i sort products, available @ 3 websites. products, available @ 1 website.
and can't figure out how approach this!
if empty fields have null value, can use
select * sometable order isnull(price_1) + isnull(price_2) + isnull(price_3) desc;
but more sensible solution be:
- you have 1 table, contains products
- you have table, contains product's id, price , value indicates website provided price.
benefits:
- you have
count(*)
entries of product in second table find out on how many listed - you can change number of websites time without changing table
Comments
Post a Comment