SELECT `employer`.*
FROM `EmployesInfo` AS `employer`
RIGHT JOIN `EmployesInfo` AS `chief` ON `employer`.`ChiefId` = `chief`.`emplId`
RIGHT JOIN (SELECT `ChiefId`, COUNT(`ChiefId`) AS `count`
FROM `EmployesInfo`
GROUP BY `ChiefId`
HAVING `count` >= 3) AS `sub` ON `employer`.`ChiefId` = `sub`.`ChiefId`
WHERE `chief`.`EmplCar` IS NOT NULL
INSERT IGNORE INTO `table` (`field1`, `field2`, `field3`)
VALUES (`valA1`, `valA2`, `valA3`), (`valB1`, `valB2`, `valB3`)
INSERT INTO `table` (`field1`, `field2`, `field3`)
VALUES (`valA1`, `valA2`, `valA3`), (`valB1`, `valB2`, `valB3`)
ON DUPLICATE KEY UPDATE `field2` = VALUES(`field2`), `field3` = VALUES(`field3`)
DELETE FROM `table` WHERE `field1` IN (`valA1`, `valB1`)
GROUP BY `c`.`id`
, только серверу добавится работы. SELECT * FROM `catalog` as `c`
INNER JOIN `atributes` AS `a1` ON `c`.`art` = `a1`.`art`
INNER JOIN `atributes` AS `a2` ON `c`.`art` = `a2`.`art`
WHERE `c`.`catalog_3` = "Видеокарты"
AND `c`.`price` != "0"
AND `c`.`avail` != "0"
AND `a1`.`names` = "Производитель"
AND `a1`.`value `IN ('ZOTAC','PALIT','ASUS')
AND `a2`.`names` = "Графический процессор"
AND `a2`.`value` IN ('nVidia GeForce GTX 660')
ORDER BY price ASC
LIMIT 0, 15
WHERE f1=xx AND f2=xx AND f3=xx
, WHERE f1=xx AND f2=xx
или WHERE f1=xx
. Если нужно ускорить поиск по другой части ключа (например WHERE f2=xx
, то надо строить отдельный индекс.