-Lost wrote:
> Response from Captain Paralytic <paul_lautman@yahoo.com>:
>
> <snip>
>
>>>> INSERT ... SELECT
>>>> http://dev.mysql.com/doc/refman/5.0/...rt-select.html
>>> Ooo, that's nice! Thanks, Captain Paralytic.
>>>
>>> To make sure I understand it correctly, I actually need to
>>> specify a target table name in the FROM clause to get it to
>>> create that temporary table?
>>>
>>> INSERT INTO tbl_temp2 (fld_id)
>>> SELECT tbl_temp1.fld_order_id
>>> -- putting tbl_temp2 below is what creates the temporary table?
>>> FROM tbl_temp1, tbl_temp2 WHERE tbl_temp1.fld_order_id > 100;
>>>
>>> I gave it a quick test, and must be screwing something up because
>>> I get tbl_temp2 does not exist.
>>>
>>> Thanks for the help.
>>>
>> This doesn't use a temporary table.
>>
>> INSERT INTO tbl_temp2 (fld_id)
>> SELECT tbl_temp1.fld_order_id
>> FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;
>
> Oh, OK. I must have misunderstood then. What does:
>
> "The target table of the INSERT statement may appear in the FROM
> clause of the SELECT part of the query. (This was not possible in
> some older versions of MySQL.) In this case, MySQL creates a
> temporary table to hold the rows from the SELECT and then inserts
> those rows into the target table."
>
> ...pertain to?
>
> Thanks again for your help, I appreciate it.
>
In previous versions of MySQL it was not possible to insert rows into the same
table they were being selected from. Now it is.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================