I’m in the process of importing data from one table to another with a completely different schema. I can import the data from one column to another just fine, but there is an autogenerated column that gets set when a new row is inserted. The code just does a count()+100001 on the table, which I’m trying to replicate in a query but I’m having issues.
Here’s my query:
insert into prospect(pid,pfirst,plast,paddress,pcity,pstate,pzip,eid,pdate,pnum,pprim)
select custid,cfirst,clast,street,city,state,zip,csrid,lastvisit,
(select count(pid)+100000 from prospect),celphone from customer limit 140000,1000;
The pnum column (the generated one) should be 100000, 100001, 100002, etc, but they all being end up 100000. I assume it’s because I’m only doing a single insert, so the count() is 0 the whole way through.
How would I accomplish what I want?
Try this:
Change the value of @auto variable as per your need in first select statement.