Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL on Two Tables where All Fields Match
Message
 
To
05/07/2001 11:43:19
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00526958
Message ID:
00527025
Views:
49
This message has been marked as the solution to the initial question of the thread.
>>Hi,
>>
>>Sorry for the uncomplete message.
>>
>>You can loop all the fields in the table and generate a where staement.
>>
>>e.g
>>
>>FOR n = 1 to FCOUNT(TableB)
>> cWhere = cWhere + 'TableB.' + FIELD(n) + '= TableA.' + FIELD(n)
>>ENDFOR
>>
>>cStatement = 'SELECT B.* FROM TableB B, TableA A WHERE ' + cWhere
>>
>>&cStatement
>>
>>Wilson
>
>Error: SQL statement too long.
>
>I'm working with 200+ fields so the list of field names goes way over the 254 limit.
>
>Looks like I'm going to need to do a scan between the tables? Any other ides before I go that route? Anyone?
>
>Renoir

Renoir, you may use a simple way: scan your table A and table B, using

SCATTER NAME command and COMPOBJ() function.

Something like:
SELECT tableA
SCAN
	SCATTER NAME oTableArec
	SELECT tableB
	SCAN
		SCATTER NAME oTableBrec
		lMatch = COMPOBJ(oTableArec, oTableBrec)
		IF lMatch
			* do something
		ENDIF
	ENDSCAN
ENDSCAN
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform