From: Davor Cengija Date: April 21 1999 3:33pm Subject: Re: [newbie] how to 'embed' SELECT into INSERT List-Archive: http://lists.mysql.com/mysql/2187 Message-Id: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 20 Apr 1999, Paul DuBois wrote: >> how can i do something like this: >> >>INSERT INTO table1 VALUES >> ("A", 1, (SELECT column FROM table2 WHERE something = >> "something")); >> >> maybe i first need to create some temp. table, INSERT INTO >> temp_table SELECT column FROM table2 WHERE etc... and then put >> those data into table1 like >>INSERT INTO table1(third_column) SELECT * FROM temp_table; >Couldn't you just use INSERT INTO ... SELECT ... with your original >table? > >INSERT INTO table1 (col1, col2, col3) >SELECT "A", 1, column >FROM table2 >WHERE etc. heh... what i need is - insert a new row into table_1 and that new row contains a few completelly new values (couldnt be found anywhere in the DB) and a few values already found in some other tables. i'm trying to do it with as little commands as possible. so, 1. insert into table_1 (col1, col2) values("new1", "new2"); 2. create temp_table etc 3. insert into temp_table select from table_2 etc 4. now what? generally speaking, i need this: UPDATE table_1 SET col3=(somehow use value from temp_table) where col1=new1; after thinking a little, i dont need steps 2 and 3 cos i could use UPDATE table_1 SET col3=(somehow use from table_2) where.. hm... it looks like i'm missing something very basic. -- v Davor Cengija Davor.Cengija@stripped ----------------------------------- "Please allow 30 days for delivery"