"Luuk" <luuk@invalid.lan> a écrit dans le message de news:
2tie65-pgm.ln1@a62-251-88-195.adsl.xs4all.nl...
>
> "Bob Bedford" <bob@bedford.com> schreef in bericht
> news:4794987d$0$3817$5402220f@news.sunrise.ch...
>> Hi all,
>>
>> I've a query wich results is returned via a "UNION". Problem is that I'd
>> like to return a distinct row so if the first select returns a record
>> based on a field, then the second must not.
>>
>> like (select idx, ....from ...)union(select idx,....from ......)
>>
>> so if idx is returned in the first select it must not in the second.
>>
>> It is possible ?
>>
>
> select id from nrs;
> 1
> 2
> 3
> 4
> 4 rows in set (0.0 sec)
>
> select id from nrs where id<4
> union
> select id from nrs where id>1;
> 1
> 2
> 3
> 4
> 4 rows in set (0.0 sec)
>
> what do you mean? i dont see your problem
Not so simple. I've a complex query:
(select idx, firstname,lastname,address,....from person inner join status on
person.idperson = status.idperson where status.statustype = 12 and
status.statusdate < '2007-01-01')
union
(select idx, firstname,lastname,address,....from person inner join group on
person.idperson = group.idperson where group.grouptype = 27 and
group.groupdate < '2007-01-01')
as you can see I have 2 different ways to get the informations and I can't
mix the 2 in the same query (as The way I link tables is quite different)