On 1/29/2010 11:02 AM, Robert Schetterer wrote:
> Am 29.01.2010 16:58, schrieb Robert Schetterer:
>   
>>
>> things with union work but , the problem
>> seems to be the double result of equal entries
>>
>> query = SELECT DISTINCT concat('@', domain,' ', username) username FROM
>> domain_admins WHERE username='%s'
>> AND domain = '%d' UNION SELECT username FROM mailbox WHERE username='%s'
>> AND active = 1
>>
>> i.e
>>
>> postmap -q "rob...@schetterer.org"
>> mysql:/etc/postfix/mysql_sasl_login_maps-test.cf
>> @schetterer.org rob...@schetterer.org,rob...@schetterer.org
>>
>> equal doubles seems to be accepted with postfix sasl map
>>     
> sorry here seems not to be accepted
>
>   
>> so i like to supress the the second result if first matched allready
>> any idea, destinct dousnt seem to help
>>     
Try adding LIMIT 1 to the end.  This will give only one result in the
precedence specified by the query when used like in
http://dev.mysql.com/doc/refman/5.0/en/union.html

(SELECT concat('@', domain,' ', username) username FROM
domain_admins WHERE username='%s'
AND domain = '%d') UNION (SELECT username FROM mailbox WHERE username='%s'
AND active = 1)
LIMIT 1


The above would return a single row with domain_admins overruling what
is in mailbox

Reply via email to