Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set relations between two tables 1

Status
Not open for further replies.

Niki_S

Programmer
Jun 4, 2021
232
LK
I have two tables and one is in foxpro and the other one is in SQL. What I want is, those tables have same fields but the field names are different.
Code:
foxpro table
nStylecode          cLotName
12345               A1
Code:
SQL table
csty_no         clot
12345           A1

Now I need to get records from foxpro table that only have records in SQL table. Something like this,
Code:
SELECT * from _DelClr where nStylecode in (SELECT csty_no FROM MIS.dbo.vInvFinal) AND clotname in (SELECT clot FROM MIS.dbo.vInvFinal)

_DelClr = foxpro table
How can I do this?

Thank you
 
Hi Niki,

there you have your root problem of trying to combine VFP data and SQL data in a query that only can see SQL data and single value parameters, but not VFP workareas or tables.

I bet you create the foxpro table from an SQL Server select. Well, and there is your solution, go back to the SQL source, a query you send to SQL Server should be extended with an INNER JOIN of MIS.dbo.vInvFinal to only return the result rows that fullfil your condition.

In the situation you have, you would need to "upload" the FoxPro _DElCLr data to SQL Server, so that it can join that to MIS.dbo.vInvFinal. And that's not the solution to aim for, solve the problem at the root, not at the situation you have now and don't create _DelClr with only half the query you need, select only the data you want in the first place.

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top