Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best way to achieve a complex SQL
Message
 
 
To
23/07/2006 20:49:11
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01139004
Message ID:
01139112
Views:
15
>>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--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform