i tried something like this but the id value is not changing, getting the value for first record and set the value for all rest…
insert into table1 (Id,b,c,d)
(select (select max(Id)+1 from table1),x,y,z from table2 where... )
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use an identity column. Then you can just do this:
If you don’t want to use an auto-increment column you can get the same effect by using adding the row number of the row instead of always adding 1. This syntax works in almost all mainstream SQL databases (not MySQL though):