Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Best way to achieve a complex SQL
Message
 
 
À
23/07/2006 20:49:11
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01139004
Message ID:
01139112
Vues:
16
>>Try,
>>
>>SELECT menu.* FROM menu  ;
>>	JOIN MenuOptions mo ON mo.NoMenu = menu.NoMenu AND mo.Enabled ;
>>UNION ;
>>SELECT menu.* FROM menu  ;
>>	JOIN MenuPriviledge mp ON mp.NoMenu = menu.NoMenu AND mp.notype = lnNotype ;	
>>	LEFT JOIN MenuOptions mo ON mo.NoMenu = menu.NoMenu  ;
>>	WHERE mo.Enabled IS NULL
>>
>
>It is amazing to see how you can view this so simply. It never occured to me to make use of the null approach to resolve this issue. Thanks a lot, this is exactly what I was looking for.

You can get the same result using correlated subquery
SELECT menu.* FROM menu  ;
	JOIN MenuOptions mo ON mo.NoMenu = menu.NoMenu AND mo.Enabled ;
UNION ;
SELECT menu.* FROM menu  ;
	JOIN MenuPriviledge mp ON mp.NoMenu = menu.NoMenu AND mp.notype = lnNotype ;	
	WHERE NOT EXISTS ( SELECT * FROM MenuOptions mo WHERE mo.NoMenu = menu.NoMenu)
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform