Кстати запрос можно написать и без IF в данном случае.
$query5 = $db->query("SELECT name, product_id,
( 0 + (name LIKE 'зелен%плать%москв') * 60
+ (name LIKE '%зелен%') * 10
+ (name LIKE '%плать%') * 10
+ (name LIKE '%москв%') * 10)) AS `relevant`
FROM " . DB_PREFIX . "product_description
WHERE language_id = 1 AND meta_keyword = '' AND (
name LIKE '%зелен%плать%москв%' OR name LIKE '%зелен%' OR name LIKE '%плать%' OR
name LIKE '%плать%')
ORDER BY relevant DESC LIMIT 1, 20");
_____________
Mysql, Postgresql, Redis, Memcached, Unit Testing, CI, Kohana, Yii, Phalcon, Zend Framework, Joomla, Open Cart, Ymaps, VK Api