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

Insert Queries 1

Status
Not open for further replies.

DirtyB

Programmer
Mar 13, 2001
159
US
Is it possible to do something like this:

Insert into Table1([field1],[field2],[field3]) values(18, select Table2.field1, Table2.Field2)

I am getting an error that says destination fields and values have a different number but they don't. That leads me to believe that my subquery is being counted as one value, when it really returns two. Has anyone encountered this before??
 
I forgot the end of the subquery


Insert into Table1([field1],[field2],[field3]) values(18, select Table2.field1, Table2.Field2 Where Table2.Field3 = 10)
 
There's an error in your values clause- the 18 should be after the select.
i.e.=Insert into Table1([field1],[field2],[field3]) values( select 18, Table2.field1, Table2.Field2 Where Table2.Field3 = 10)
Assuming that 18 is to be entered in Table1.Field1.

Good Luck!
 

You don't need the values clause.

Insert into Table1([field1],[field2],[field3])
Select 18, Table2.field1, Table2.Field2
Where Table2.Field3 = 10 Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it and comment if you have time.
NOTE: Reference to the FAQ is part of my signature and is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top