I have a table like,
BatchID Volume1 Volume2 Volume3
1 3.0 4.0 5.0
1 2.0 1.0 2.0
2 1.0 2.0 4.0
2 1.0 1.0 1.0
2 1.0 1.0 1.0
I am trying to add another batchid 3 with same volume1, volume2 and volume3 values
such that it looks like (same records from batchID 2)
1 3.0 4.0 5.0
1 2.0 1.0 2.0
2 1.0 2.0 4.0
2 1.0 1.0 1.0
2 1.0 1.0 1.0
3 1.0 2.0 4.0
3 1.0 1.0 1.0
3 1.0 1.0 1.0
I wrote the following query
insert into table1 (BatchID,Volume1,Volume2,Volume3) Values
(`3`,Select Volume1,Volume2,Volume3 from table1 where batchid = '2')
gives an error.
P.S I know the above is not a good database design. This is over simplified version of my actual design.
You can use
INSERT ... SELECT: