Order by price (but multiple currencies in one column)... how to?

Discussion in 'MySQL' started by AmidalaX, Aug 8, 2010.

  1. #1
    Hi there, I have one problem.

    I have table like this:
    prod_id, prod_cur, prod_price....

    For example I have these rows:
    1, EUR, 100
    2, USD, 101

    When I use simple order by prod_price, 101 USD will be more than 100 EUR. How to correct this?

    Thank you.
     
    AmidalaX, Aug 8, 2010 IP
  2. AmidalaX

    AmidalaX Greenhorn

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #2
    Ok solved :)

    If somebody need this, I found solution in this:

    SELECT prod_id, prod_cur, 
    CASE prod_cur
    WHEN "EUR" THEN prod_price
    WHEN "USD" THEN prod_price / 1.3176
    END
    as prod_price
    FROM products ORDER BY prod_price
    Code (markup):
     
    AmidalaX, Aug 8, 2010 IP