At 13:26 -0500 6/17/02, Mike wrote:
>Here's an interesting problem I'm having with an insert query.
>I need to add 5000 records to a run table without duplicating
>records within the current job or without duplicating records from a
>previous reference job.
>Here's the query I need to run. Unfortunately, MySQL won't take my
>referencing the insertee table within the select even if it's a join.
>insert into run (job_id,cust_id,thread_id) select '$job_id',oid,0
>from main left join log on main.oid = log.cust_id and log.job_id =
>'$refjob' left join run on main.oid = run cust_id and run.job_id =
>'$refjob' where tag='Test' and main.cust_id is not null order by
>rand() limit 5000
You can't select records from the same table into which you're inserting
>If necessary, I'll toss up the column layouts.
>thanks for the assist,