Results 1 to 2 of 2
May 14, 2011, 03:14 #1
- Join Date
- May 2006
- 0 Post(s)
- 0 Thread(s)
calculating difference with mysql
I want to run a query to fetch 10 rows from database with the 'category_id' parameter set, and fall back if there are not 10 rows from the mentioned category to fetch the missing rows from the same table without category_id.
How can you calculate a difference with php?
Right now I call this query:
(SELECT asin FROM products $where ORDER BY $order_by LIMIT 10) UNION (SELECT asin FROM products WHERE site_id = $site_id ORDER BY $order_by LIMIT 10)
Which would be more elegant way to do this with mysql?
Thanks for help