Walter Meester
HoogkarspelPays-Bas
Information générale
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
John,
>I have a subquery which made use of UNION. Is there any INTERSECT equivalent SQL statement which can be used with UNION?
>((select * from table1
>UNION
>select * from table2) INTERSECT
>(select * from table3))
SELECT * FROM Table1 UNION Select * FROM Table2 INTO CURSOR x
SELECT * FROM x UNION ALL SELECT * FROM Table3 INTO CURSOR y
SELECT * FROM Y GROUP BY allfields... HAVING COUNT(*) = 2
would produce the desired result if in each table there is an existing primary key (so multiple exact same records cannot exist in one table).
I have not tried it, but you might be able to combine statement 2 and 3 to:
SELECT * FROM x UNION ALL SELECT * FROM Table3 GROUP BY allfields... HAVING COUNT (*) = 2
HTH
Walter,
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement