Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Complicated SQL statement
Message
 
To
26/03/2008 14:05:44
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01305759
Message ID:
01305926
Views:
14
>Thanks this works great. But I still have on slight problem. The contractors table has a notes field in it but the HR table does not. I really need this data to be reported on the contractors.
Something like:
CLOSE DATA ALL
SET ENGINEBEHAVIOR 90
CREATE CURSOR crsTest (badge int)
INSERT INTO crsTest VALUES (1)
INSERT INTO crsTest VALUES (2)
INSERT INTO crsTest VALUES (3)


CREATE CURSOR crsHR (badge int, Name C(20))
INSERT INTO crsHR VALUES (1, 'Guy 1')
INSERT INTO crsHR VALUES (2, 'Guy 2')


CREATE CURSOR crsContr (badge int, Name C(20), NOTES M)
INSERT INTO crsContr VALUES (1, 'Guy 1',[1])
INSERT INTO crsContr VALUES (3, 'Guy 3',[2])


SELECT crsTest.badge, Tbl1.Name, Tbl1.Notes;
 FROM crsTest;
INNER JOIN (SELECT Tbl1.badge, Tbl1.Name, NVL(crsContr.Notes,CAST([] AS M)) AS Notes;
                  FROM (SELECT badge, Name FROM crsHR;
                              UNION;
                        SELECT badge, Name FROM crsContr) Tbl1;
            LEFT JOIN crsContr ON Tbl1.badge = crsContr.Badge) Tbl1;
ON crsTest.badge = Tbl1.badge
NUT keep in mine that IF you have exact the same guy in H system and Contracts table and He/She is filtered by UNION you could get no NOTES field!
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform