Link to home
Start Free TrialLog in
Avatar of developingprogrammer
developingprogrammer

asked on

insert sql using both VALUES and SUB-QUERY

hi guys,

i can write an insert query and use VALUES to insert the data i want. i can also use a subquery to insert the data. can i use a mixture of 2 or must i write 2 queries?

e.g. join the 2 lines of code into 1

Sub InsertQuery_UsingValuesOnly()
    Call CurrentDb.Execute("INSERT INTO DestinationTable (TableField1, TableField2) VALUES (""something1"", ""something2"");")
End Sub
Sub InsertQuery_UsingSQLOnly()
    Call CurrentDb.Execute("INSERT INTO DestinationTable (TableField1, TableField2) SELECT ExistingInformation.Existing1, ExistingInformation.Existing2 FROM ExistingInformation;")
End Sub

Open in new window

Avatar of als315
als315
Flag of Russian Federation image

Do you like to insert some default values if you have no existing data in ExistingInformation?
Avatar of developingprogrammer
developingprogrammer

ASKER

Yes I would = )
SOLUTION
Avatar of als315
als315
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
yup guys i agree, it may take a bit too much effort - i should just keep it simple = ) thanks guys!! = ))