mysql - I'm in need of a sanity check on a sql query that will return a value if it exists in the table or return a default value if it doesn't -
What I'm trying to do is returning a mailbox location for some select users and for everyone Catch all mailbox locations. In the postfix you can select mailbox from the
e-mail = '% s'
mailbox and it will be sent to the% email user Is searching with it. I have a table that contains a group of users that require their mailbox (root, support, postmaster) and I want to be able to create a query that gives the configured mailbox or 'all /' example If the user name is 'support', then I want to draw the mailbox column for the username 'support'. If the user name is 'someone' that does not match one row in the table, then I want to return it 'all /'.
Here I come up with the query. Select when v2.username is not enabled, v2.mailbox mailbox2 virtual_mailboxes v1 left virtual_mailboxes v2 ON v2.username = SUBSTRING_INDEX (support@gmail.com ',' @ ', 1) LIMIT 1 as ELSE' all / 'END
This works but I think it is very wrong to do this and if I have a better way then I am curious.
Another thing, thanks to any help, the postfix will only replace the first event of% s.
(select from virtual_mailboxes where mailboxes where email = '% s') , 'All /');
Comments
Post a Comment