Welcome to WebmasterWorld Guest from 54.234.95.190

Forum Moderators: open

Message Too Old, No Replies

Is this possible in Mysql

     

Elric99

9:14 am on Aug 17, 2010 (gmt 0)

10+ Year Member



If I have a table with 100 products in it, half are from Brand A, half are from Brand B. How do I say:

SELECT * FROM table_name
LIMIT 20
BUT ... show 10 products from Brand A and 10 products from Brand B

Maybe it's early but I can't quite get my head around how to write this query.

Thanks!

brotherhood of LAN

11:51 am on Aug 17, 2010 (gmt 0)

WebmasterWorld Administrator brotherhood_of_lan is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



You can use the UNION operator, so something like this should be good.

SELECT * FROM table WHERE product = 'a' LIMIT 10
UNION
SELECT * FROM table WHERE product = 'b' LIMIT 10
 

Featured Threads

Hot Threads This Week

Hot Threads This Month