SELECT
storefronts.*
FROM
cscart_storefronts AS storefronts
WHERE
1 = 1
AND (
storefronts.url = 'tochkasvyazi.test-handyhost.ru'
OR storefronts.url = 'www.tochkasvyazi.test-handyhost.ru'
OR storefronts.url LIKE 'www_.tochkasvyazi.test-handyhost.ru'
OR storefronts.url LIKE 'tochkasvyazi.test-handyhost.ru/%'
OR storefronts.url LIKE 'www.tochkasvyazi.test-handyhost.ru/%'
OR storefronts.url LIKE 'www_.tochkasvyazi.test-handyhost.ru/%'
)
GROUP BY
storefronts.storefront_id
ORDER BY
storefronts.url = 'tochkasvyazi.test-handyhost.ru' DESC,
storefronts.url = 'www.tochkasvyazi.test-handyhost.ru' DESC,
storefronts.url LIKE 'www_.tochkasvyazi.test-handyhost.ru' DESC,
storefronts.url LIKE 'tochkasvyazi.test-handyhost.ru/%' DESC,
storefronts.url LIKE 'www.tochkasvyazi.test-handyhost.ru/%' DESC,
storefronts.url LIKE 'www_.tochkasvyazi.test-handyhost.ru/%' desc