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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql statement ?

Status
Not open for further replies.

engan

Programmer
Jul 15, 2001
53
ID
Dear All,

I am trying to write a select statement with the following situation :


Table1 (Order.dbf) Table2 (Customer.dbf)(For Customer and Agent)
OrderNo C12 IDCust C12
IDCustomer C12 IDName C30
IDAgent C12

I want my sql result to be

OrderNo IDName IDName
OrderNo IDName IDName

where the first column IDName is from IDCustomer and the second column IDName is IDAgent

How do I write the sql statement with the above situation ?

Thanks
Eng An
 
Try this one:

Code:
select A.OrderNo, B.IDName as custname, C.IDName as agentname ;
from Table1 A left outer join Table2 B on B.IDCust == A.IDCustomer ;
			  left outer join table2 C on C.IDCust == A.IDAgent	;
into cursor mycursor
 
Craig Bernston,

What I did is I store only ID Customer and ID Agent in order.dbf. Then I want to generate data using sql where the fisrt column is orderid, 2nd column is the name of the customer, then 3rd column is the name of the agent where both name is stored in one file called customer.dbf

So the result of sql query might look like this

Order No. Customer Name Agent Name
000000001 John Peter
000000002 Marry Ann
.
.
etc

Eng An


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top