This is the table i got with table name photos:
photo_id user_id
401 1
403 1
405 1
407 2
408 1
409 2
410 1
411 3
412 2
413 2
420 2
423 2
I am Currently Using the Query
SELECT *
FROM photos
WHERE user_id
IN ( 1, 2 )
LIMIT 0 , 6
Ids inside IN
can have multiple values not just two
What I Get Is
photo_id user_id
401 1
403 1
405 1
407 2
408 1
409 2
Without Having Proportionate values for each user_id
What I Want is Get Values in Equal Proportion from both UserIds. That is if fetching limit is 6 then i need 3 values or less than 3 if less than 3 elements exists from 1 and 3 values or less than 3 if less than 3 elements exists from 2
And If there are 3 user ids and fetching limit is 6; All three ids will have result with value of 2
photo_id user_id
401 1
403 1
405 1
407 2
409 2
412 2
I can Do it in Multiple queries ; But Is there any way to do it in single query;