 |
|
 |
sneha Level: Scholar
 Registered: 28-03-2006 Posts: 29
|
Re: Combine Two Tables Into One
quote: stickleprojects wrote:
Hi,
Create and Run 2 insert queries in access the copies the data into this new table... Kieron
Hi, I have similar problem but I don't know about the insert queries . Could you please write the insert querries for me? The following are the fields:
Table1 : Sales fields for this table are as follows:
CustomerName
InvoiceNo
InvoiceDate
InvoiceAmount
Table2 : Payment fields for this table are as follows:
CustomrName
PaymentMode
PaymentDate
PaymentReceived
What I need from the above tables is it should show the following data in Table3.
Table3 : AccountBalance fields for this tables are as follows:
CustomerName
InvoiceDate
InvoiceAmount
PaymentDate
PaymentReceived
Please note that it is not a relational database (What I mean is, there is no relation between CustomerName in two tables). Simple access database with 2 tables.
Thanks in Advance.
____________________________
Sneha
|
|
28-03-2006 at 06:09 PM |
|
|
sneha Level: Scholar
 Registered: 28-03-2006 Posts: 29
|
Re: Combine Two Tables Into One
quote: Chris_871 wrote:
Hi
Insert query for your sales table..
SqlSales = "Insert into Sales (CustomerName,InvoiceNo,InvoiceDate,InvoiceAmount) values ('" & trim(custname) & "','" & trim(invno) & "'," & (invdate) & "," & (invamt) & ")"
Regards
Chris
Thanks.
Actually I need the Insert Querry for the Target Table " AccountsBalance" with the following fields from Sales table and Payment table:
CustomerName
InvoiceDate
InvoiceAmount
from Sales table &
PaymentDate
PaymentReceived
from Payment table
Thanks in Advance.
[Edited by sneha on 29-03-2006 at 12:43 PM GMT]
____________________________
Sneha
|
|
29-03-2006 at 04:41 AM |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
Re: Combine Two Tables Into One
I dont understand how to you think to join two tables, if no relationship between them exists? And why are those two tables split, since there is no benefit from the split? Anyway, if you know for sure that there is one and only one record in both databases for one customer, then this is how it can be done:
firt run this query
| INSERT INTO AccountsBalance (CustomerName,InvoiceDate,InvoiceAmount) SELECT CustomerName, InvoiceDate, InvoiceAmount FROM Sales |
and then this query
| UPDATE AccountsBalance a INNER JOIN Payment p ON a.CustomerName=p.CustomerName SET a.PaymentDate=p.PaymentDate, a.PaymentReceived=p.PaymentReceived |
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
29-03-2006 at 09:16 PM |
|
|
|
|
 |
 |