Hi i need help with queries. here is my query & table structure.
SELECT *
FROM products_description a, products b
where a.products_id=b.products_id
AND b.products_status >0
AND a.products_name LIKE '%".$q."%'
ORDER BY b.products_quantity DESC LIMIT 10
---------------------------------------------------
| products_id | products_name | products_quantity |
---------------------------------------------------
| 980 | SOS | 21 |
---------------------------------------------------
| 101 | GOLD | 9 |
---------------------------------------------------
| 232 | BALL | 1 |
---------------------------------------------------
| 422 | SONG | O |
---------------------------------------------------
| 371 | ALL | O |
---------------------------------------------------
| 72 | FISH | O |
---------------------------------------------------
I would like it to sort so that it is alphabaticaly ordered(product_name) while keeping those with 0 quantity at the bottom. Typically, i would like such result:
---------------------------------------------------
| products_id | products_name | products_quantity |
---------------------------------------------------
| 980 | Ball | 1 |
---------------------------------------------------
| 101 | GOLD | 9 |
---------------------------------------------------
| 232 | SOS | 21 |
---------------------------------------------------
| 422 | All | O |
---------------------------------------------------
| 371 | FISH | O |
---------------------------------------------------
| 72 | SONG | O |
---------------------------------------------------
Appreciate any help!
1 Answer