Reputation: 9476
I am trying to select already inserted data and want to insert same data into same table. Just one field is change .So i have tried something like this but it is not working.
INSERT INTO TABLENAME (field2, field3,2)
SELECT field2,field3 FROM TABLENAME
Please help.
Upvotes: 2
Views: 3358
Reputation: 311393
You have mixed up column names with their values. The insert into
clause use column names which determine where the data should be inserted to. In the select
list you can have column names, constant or calculations:
INSERT INTO tablename (field2, field3, field_with_constant_value)
SELECT field2, field3, 2
FROM tablename
Upvotes: 1
Reputation: 18600
First you have to specify fieldName in Insert Query
and In select query you have to specify new value which you want to insert like :
INSERT INTO TABLENAME (field2, field3, field4)
SELECT field2,field3,2 FROM TABLENAME
Upvotes: 1