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