Not sure if you can do that in a single query, it might be 2 queries LIMIT 10 just using
WHERE merchant LIKE merchant_a / merchant_b
If I have a table with 100 products in it, half are from merchant A, half are from merchant B. How do I say:
SELECT * FROM table_name
LIMIT 20
BUT ... show 10 products from merchant A and 10 products from merchant B
Maybe it's early but I can't quite get my head around how to write this query.
Thanks
Not sure if you can do that in a single query, it might be 2 queries LIMIT 10 just using
WHERE merchant LIKE merchant_a / merchant_b
Think this should work:
(SELECT product_id, product_name FROM table_name WHERE merchant_id = 1 LIMIT 10)
UNION (SELECT product_id, product_name FROM table_name WHERE merchant_id = 2 LIMIT 10)
Just need to remember to ensure the field names in both selects are the same
Cheers
Tobman (17-08-10), umbrella-technologies (17-08-10)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks