-1

I have 4 tables: bol, eci, ako, voordeel_boeken_online. Some of the tables has a price for the book with isbn 9780002261357. I checked it with the following query:

SELECT bol.price as bol_price
     , eci.price as eci_price
     , ako.price as ako_price
     , voordeel_boeken_online.price AS voordeel_boeken_online_price 
  FROM books
  LEFT 
  JOIN bol 
    ON bol.product_id = bol_id
  LEFT 
  JOIN eci 
    ON eci.product_id = eci_id
  LEFT 
  JOIN voordeel_boeken_online 
    ON voordeel_boeken_online.product_id = voordeel_boeken_id
  LEFT 
  JOIN ako 
    ON ako.product_id = ako_id
 WHERE isbn = '9780002261357' 
 ORDER 
    BY bol.price
     , eci.price
     , ako.price
     , voordeel_boeken_online.price

But it gives me this output:

enter image description here

I want the lowest price first, but it doesn't do that. What am I doing wrong?

Strawberry
  • 33,750
  • 13
  • 40
  • 57
jurh
  • 420
  • 1
  • 4
  • 17
  • In which order? you can do `bol.price ASC` Which would start by ordering the rows by `bol.price` in ASC – Toleo Feb 12 '18 at 18:18
  • See: [Why should I provide an MCVE for what seems to me to be a very simple SQL query?](https://meta.stackoverflow.com/questions/333952/why-should-i-provide-an-mcve-for-what-seems-to-me-to-be-a-very-simple-sql-query) – Strawberry Feb 12 '18 at 18:19
  • 1
    Are you saying you want the *column* order to be dictated by the prices? That's... not normal. – iainn Feb 12 '18 at 18:19
  • You tagged PHP, so just fetch the row and `sort` it. – AbraCadaver Feb 12 '18 at 18:20

1 Answers1

0

you can do something like the example given below just use the query to select the minimum SELECT * FROM product WHERE bol.price = ( SELECT MIN(bol.price) FROM product )

Sammy
  • 1
  • 2