Re: Copying a set of database records
| From: | Martin Norland | Date: | Fri, 04 Mar 2005 17:04:28 +0000 |
| Subject: | Re: Copying a set of database records | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-38773@lists.php.net to get a copy of this message | ||
Jesper Goos wrote:
Hi It can't be done in a single SQL query as SQL can't make recursive requests. You will have to use PL/SQL, and I don't think MySql supports that. [snip]<bubble burst="true" mysql_version_required="4.1"> http://dev.mysql.com/doc/mysql/en/subqueries.html </bubble>
Steve McGill wrote:Optionally, you could do it in multiple queries using a temporary table. Yes it's not a single mysql query, but it doesn't have to pop out and do any iteration in PHP, which does keep it cleaner and more organized. Cheers, -- - Martin Norland, Sys Admin / Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital.I have a table with about 100 records all related to one product. I want to create a new product, based on the details from the old product. So in PHP, I would fetch the 100 records, alter the productID, and then insert it 100 in 100 separate SQL queries. Is there any way I can do this in one SQL query, somehow using a combination of insert and select? [snip]