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