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
, то надо строить отдельный индекс. SELECT `cat`.`id` AS `catId`, `cat`.`title` AS `catTitle`, `subcat`.`title` AS `subcatTitle`
FROM `categories` AS `cat`
LEFT JOIN `subcategories` AS `subcat` ON `cat`.`id` = `subcat`.`cat_id`
ORDER BY `cat`.`id`
<?php
$cat = -1;
foreach ($result as $row) {
if ($row['catId'] != $cat) {
echo ($cat == -1 ? "" : "<\li>")."<li><p class='categories'>{$row['catTitle']}</p>";
$cat = $row['catId'];
}
echo "<p class='subcats'>{$row['subcatTitle']}</p>";
}
if ($cat != -1)
echo "</li>";
?>