You probably should specify the fields for the insert. MySQL is probably inserting into
the ID field because you didn't specify
which fields to use for inclusion.
INSERT INTO jobs (field1,field2,...) (SELECT...)
----- Original Message -----
From: "John Kopanas" <john@stripped>
To: <mysql@stripped>
Sent: Thursday, April 12, 2007 10:42 PM
Subject: Re: Why Is Autonumber Not Working With Following Query
> Wow, I am a little tired... this is the query causing me the problem...
>
> INSERT INTO jobs
> (SELECT * FROM tmpJobs WHERE NOT EXISTS
> (SELECT * FROM jobs WHERE jobs.customer_number <=>
> tmpJobs.customer_number and jobs.job_number <=> tmpJobs.job_number));
>
> Why is the id not creating distinct #s?
>
> On 4/12/07, John Kopanas <kopanas@stripped> wrote:
>> I have the following query:
>>
>> INSERT INTO summaries (entity_name, job_type, job_status)
>> (SELECT entity_name, "GOV", "Non-Workable" FROM tmpSummaryTable);
>>
>> The only other column I have is id and it is primary key autonumber int.
>>
>> Why would I get the following error?
>>
>> ERROR 1062 (23000) at line 3: Duplicate entry '5' for key 1
>>
>> Why is the query trying to enter a duplicate entry?
>>
>> This makes no sense to me :-).
>>
>> Thanks
>>
>> John
>>
>> --
>> John Kopanas
>> john@stripped
>>
>> http://www.kopanas.com
>> http://www.cusec.net
>> http://www.soen.info
>>
>
>
> --
> John Kopanas
> john@stripped
>
> http://www.kopanas.com
> http://www.cusec.net
> http://www.soen.info
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=1
>