Re: [SOLVED] RE: mySQL Query not working
- Tino Donderwinkel a écrit :
> The problems was in here:What does this do that is not done with:
> %u When the input key is an address of the form
> user@domain, %u is replaced by the SQL
> quoted local part of the address. Other-
> wise, %u is replaced by the entire search
> string. If the localpart is empty, the
> query is suppressed and returns no results.
> The solution is very dirty;
> SELECT rcpt FROM aliases WHERE alias IN ('%s',(SELECT REPLACE('%s', '@%d',
> CONCAT('@', alias_of)) FROM domains WHERE domain = '%d'))
SELECT alias_of FROM domains WHERE domain = '%d'
> I'd really like to find out WHY the query is suppressed when %u is used andSince postfix will lookup domains in many maps, suppressing the lookup
> %u is empty....
reduces overhead. for example, with the suggested query above, postfix
doesn't need to search for "joe@domain'. it will directly search for
for the rare case where you want to check that it is a domain (or
@domain), use SQL for that. for example, if
> select substring_index('user@domain', '@', 1);...
> select substring_index('user@domain', '@', -1);...
>(yes, this doesn't handle the ugly 'joe@domain1@domain', but do you want
note that your lengthy query can be rewritten to avoid the overhead:
SELECT rcpt FROM aliases, domains WHERE domain = '%d' AND
alias = CONCAT(
substring_index('%s', '@', 1),