Advertisement
bpoole

MySQL GROUP_CONCAT Emails

Jul 31st, 2015
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.42 KB | None | 0 0
  1. #take a table of email addresses [table: alias; fields: domain, address, goto] and generate a list of email settings for each domain
  2. select domain, group_concat(case when address != goto then concat(address, ' -> ', goto) when address = goto then address end order by address separator ', ') from alias group by domain;
  3.  
  4. #generates a result like
  5. #| example.com    | user@example.com, info@example.com -> user@example.com |
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement