I have a table with the following:
+----+-------+-------+-----------+-----------+--------------+--------------+
| id | stock | price | usedStock | usedPrice | specialStock | specialPrice |
+----+-------+-------+-----------+-----------+--------------+--------------+
| #1 | 1 | 10.00 | 0 | 0 | 0 | 0 |
| #2 | 0 | 0 | 1 | 15.00 | 1 | 20.00 |
| #3 | 0 | 0 | 0 | 11.00 | 1 | 14.00 |
+----+-------+-------+-----------+-----------+--------------+--------------+
I would like to create a query that orders by lowest price first if the type of item is in stock.
So the query would result in the following order:
#1 - 10.00 (because 10.00 is the lowest result)
#3 - 14.00 (because although 11.00 is less, it's not in stock)
#2 - 15.00 (because 15.00 is lower than 20.00)
I've added the PHP tag to this question in case there's a quicker way of calculating using PHP after selecting the table.