There is a query, for example:
SELECT `id`,`id_category` FROM `items` WHERE `id_category` IN(22333,23433,23454 и т.д) AND `public` = 1 In each id_category there can be a set id where public == 1 Question: Is it possible to write sql, by which mysql having found the first id with public = 1, went to the next id_category in the list? those. no need to look for all the records, but only the 1st in each category.


select distinct id_category from ...if there is an index on the fields(id_catgory, public)should work quickly. - Mikeid_categoryfield (or the composite indexid_category, public- you need to look at the plan) and the query will fly - Anton Shchyrov