Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
I need to put something - if it's there or not
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01147940
Message ID:
01149737
Views:
6
>I've no way of knowing. I inherited the "database" from an old DOS system. There are different databases for different bus regions, and the exe is duplicated in each of their folders, thus pointing at a different set of data each time. It's my understanding that operators' data are not to be out put if they don't have an RF1 record.
>
Hi Terry,

Try following query
CLOSE DATABASES

CREATE CURSOR NET (Operator C(3), Route C(3))
INSERT INTO net VALUES ("001", "101")
INSERT INTO net VALUES ("001", "301")
INSERT INTO net VALUES ("002", "101")
INSERT INTO net VALUES ("002", "201")
INSERT INTO net VALUES ("002", "401")
INSERT INTO net VALUES ("003", "102")
INSERT INTO net VALUES ("003", "103")

CREATE CURSOR RF1 (Operator C(3), Route C(3), Service C(1))
INSERT INTO rf1 VALUES ("001", "101", "A")
INSERT INTO rf1 VALUES ("001", "301", "B")
INSERT INTO rf1 VALUES ("002", "101", "A")
INSERT INTO rf1 VALUES ("002", "   ", "X")
*INSERT INTO rf1 VALUES ("002", "201")
INSERT INTO rf1 VALUES ("002", "401", "D")
*INSERT INTO rf1 VALUES ("003", "102", "E")
INSERT INTO rf1 VALUES ("003", "   ", "Z")
*INSERT INTO rf1 VALUES ("003", "103")

SELECT net.Operator, Net.Route, rf1.Service ;
	FROM net ;
		JOIN rf1 ON rf1.Operator = net.Operator ;
			AND  rf1.Route = net.Route ;
UNION ALL ;
SELECT net.Operator, Net.Route, rf1.Service ;
	FROM net ;
		JOIN rf1 rf1_1 ON rf1_1.Operator = net.Operator ;
			WHERE EMPTY(rf1_1.Route) ;
						AND NOT EXISTS ( ;
							SELECT * FROM rf1 rf1_2 WHERE rf1_2.Operator = net.Operator ;
								AND rf1_2.Route = net.Route)
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform