Advertisement
Guest User

Untitled

a guest
Aug 16th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.39 KB | None | 0 0
  1.  SELECT destination
  2.     FROM
  3.         (SELECT destination, email, wildcard, localpart FROM alias
  4.             UNION
  5.              SELECT email AS destination, email, 0 AS wildcard, localpart FROM USER)
  6.     WHERE
  7.     (
  8.      wildcard = 0
  9.      AND
  10.      email = '%s'
  11.     ) OR (
  12.      wildcard = 1
  13.      AND
  14.      '%s' LIKE email
  15.     )
  16.   ORDER BY
  17.     wildcard ASC,
  18.     LENGTH(localpart) DESC
  19.   LIMIT 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement