F
F
fiter2017-10-07 22:05:48
MySQL
fiter, 2017-10-07 22:05:48

Mysqli: how to make a limit select for a pair of IN values?

There is a table contactswith fields id|city_id|category_id|email
Now the query is:

"SELECT (id,email) FROM contacts WHERE city_id IN (".implode(',', $arrCity).") AND category_id IN (".implode(',', $arrCategory).")"

How can I select 10 entries for each city->category pair?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2017-10-07
@Rsa97

IMHO, only via UNION subqueries for each pair

D
Dmitry Gadzhiev, 2017-10-08
@gds1

I agree with Rsa97, make 2 requests with limits, and unite them with UNION.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question