At 4:51 PM -0700 10/31/01, Nathan wrote:
>I have a table(2) with a different structure than the table(1) I'm
>selecting from. I want to be able
>to grab some info from table1, put it in table2, along with some
>variables from my php page. Is it
>possible to do like:
>INSERT INTO table2 VALUES 1,2,3 SELECT 4,5,6 FROM table1
>Or do I need to select into a temp table or my php form, get it all
>in the right order, then insert
>it back into table2?
You can do it, but you don't use a VALUES clause. Put all the values
in the SELECT statement.
For example, if you want set set columns a, b, c in table2 to
the contants 1, 2, and 3, and set the columns d, e, and f to
columns g, h, and i from table1, you'd do this:
INSERT INTO table2 (a, b, c, d, e, f) SELECT 1, 2, 3, g, h, i FROM table1