Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)
I have two tables tbl_std(std_id,std_name,section_name) & tbl_division(div_id,div_name,std_id,) and tbl_third(std_id,div_id,field_1,field_2).

Now I want to select std_id from tbl_std and div_id from tbl_div and insert these records into third table tbl_third.

I have tried using inner joins but failed to insert the data.
I am using mysql database.

Please help.
Posted
Updated 27-Mar-15 22:08pm
v3
Comments
Rajesh waran 28-Mar-15 3:58am    
Can you show what you have tried?

1 solution

Try like this, but don't know where you have struck.
SQL
insert into tbl_third(std_id,div_id,field_1,field_2) 
select a.div_id,b.std_id,'1' as Field1,'2' as Field2 from tbl_division as a inner join tbl_std as b on a.std_id=b.std_id
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900