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

Help with insert statement

Status
Not open for further replies.

dmoonme

MIS
Jul 21, 2004
33
US
Hi, I am a rookie at this and so I thank you for your help in advance.

Basically I have 3 tables. TableA and TableB have the data I want to put into TableC. I only want to put records into TableC.Column1 where TableA.Column1=TableB.Column2

I tried and tried but I can't figure it out. Please help!
 
after fixing the table names and field names (not COLUMNS!! They are FIELDS!!!)run this query (open the query design in SQL mode and copy and paste, then switch to datasheet view to check the results)

Code:
SELECT * FROM TABLEA INNER JOIN TABLEB ON TABLE1.FIELD1 = TABLE2.FIELD1

if this query returns the correct information then you have two choices. One of the menu choices will allow you to save this as a Make Table query. Then it will make the table for you. If you have a table created already, then change TABLEC to the correct table name and run this query:

Code:
INSERT INTO TABLE_C
SELECT * FROM TABLEA INNER JOIN TABLEB ON TABLE1.FIELD1 = TABLE2.FIELD1

all the fields from the query results HAVE to be in TableC; if they aren't you will need a slightly different structure.

HTH




Leslie
 
After putting parameter value "abc" for TableA.Field1 and TableB.Field1 I get this error "Duplicate output destination 'id'. I used this query of yours:

INSERT INTO TABLE_C
SELECT * FROM TABLEA INNER JOIN TABLEB ON TABLEA.FIELD1 = TABLEB.FIELD1

 
i would have to guess that the record you are trying to insert into Table_C already exists.

Leslie
 
Thanks for your help lespaul. I played around with your query and finally came up with this. It seems to work for me.

Code:
INSERT INTO TABLE_C
SELECT *
FROM TABLEA, TABLEB
WHERE [TABLEA].[CaseName]=[TABLEB].[MatterName];
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top