Sunday, 15 January 2012

Filling a mysql table combining data from two tables -



Filling a mysql table combining data from two tables -

i have 2 tables

table 1 table2 id_1 id_2 name 1 10 name1 2 20 name2 3 4 5

i need query one, each id_1 result gets many registers table 2 has.

table3 id_3 id_1 id_2 name 1 1 10 name1 2 1 20 name2 3 2 10 name1 4 2 20 name2 5 3 10 name1 6 3 20 name2 7 4 10 name1 8 4 20 name2 9 5 10 name1 10 5 20 name2

could help me? thanks

edit:

well, both of you.

finally got easy solution.

select * table1 cross bring together table2

i didn´t know cross join operator. , gives combination of each register first table each register second.

thanks again

try this:

insert table3 select t1.id_1,t2.id_2,t2.name table1 t1, table2 t2

mysql

No comments:

Post a Comment