Du kan nemt sortere resultaterne efter antallet af kampe:
SELECT `id`
FROM `accounts`
WHERE AES_DECRYPT(`email`, '123') = CONCAT_WS('@', 'test', 'test.com') OR
AES_DECRYPT(`email`, '123') LIKE CONCAT('%','test.com')
ORDER BY ( (AES_DECRYPT(`email`, '123') = CONCAT_WS('@', 'test', 'test.com')) +
(AES_DECRYPT(`email`, '123') LIKE CONCAT('%','test.com'))
);
Dette vil fungere for dit eksempel.