Forum Moderators: open

Message Too Old, No Replies

How do i write this in SQL?

         

darkage

10:56 am on Jun 30, 2007 (gmt 0)

10+ Year Member



Basically this is the pseudo code I want to write in sql:

For each row in table A
-----Insert row in table B with data from table A

This is what Im trying with:

insert into A (col1, col2, col3) values (select col1 from B, blabla, blabla);

Obviously this doesnt work as the "select col1 from B" returns multiple values.

So how do i do this without triggers in mysql?

Thanks in advance.

syber

12:53 pm on Jun 30, 2007 (gmt 0)

10+ Year Member



insert into A (col1, col2, col3)
select col1, col2, col3
from B

darkage

7:40 pm on Jun 30, 2007 (gmt 0)

10+ Year Member



Worked perfect.

I knew it could be done, was just not sure on the syntax.

Thanks!