Re: Combining INSERT...SELECT and INSERT INTO

From: Date: Tue, 15 Jan 2002 14:04:19 +0000
Subject: Re: Combining INSERT...SELECT and INSERT INTO
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-15824@lists.php.net to get a copy of this message
On 1/14/2002 12:54 PM +0200 Markus Lervik wrote:
Is there any way to combine INSERT...SELECT and INSERT INTO so one could insert a new row with a few values inserted by hand and others from another table? something like INSERT INTO mag_table (mag_id,issn,year,info,volume,numbers,remarks) VALUES ( (SELECT id FROM mag_names WHERE mag_names.name="Asdf"), "1234-5678","2001","foobar","1-4","1-52","foobar");
Try doing something like: INSERT INTO mag_table (mag_id,issn,year,info,volume,numbers,remarks) SELECT mag_names.id as mag_id, '1234-5678' as issn, '2001' as year, 'foobar' as info, '1-4' as volume, '1-52' as numbers, 'foobar' as remarks, FROM mag_names WHERE mag_names.name='Asdf'; I don't know if that will work as-is, but something along those lines should give you what you need. Cheers, Toby -- Tobyn Baugher <toby@cartoonviolence.net> http://www.cartoonviolence.net/

« previous php.db (#15824) next »