i want to insert data into third table for two tables
that is first table:table struct: pid -->int,name-->string ..etc
second table :cid -->int,parentid-->int....etc
third table struct is:pid-->int,cid-->int
now iwant to insert data into third table from the other two tables
pid from first table is a prime key and pid from third is a foreign key to it
cid-->prime key and cid in third table is foreign to it.
i.
srpa01red
0
Newbie Poster
Recommended Answers
Jump to PostHi srpa01red and welcome to DaniWeb,
This is certainly doable. But I have to ask, if the third table only contains those two fields, is it necessary to create the third table? From the looks of the structure of the second table, you already have that information in that …
Jump to PostYou can do it in following manner
insert into table3 (pid,cid) select a.pid,b.cid from table1 a cross join table2 bAs darkagn said, your case doesnt need this to be done. Its already there
All 6 Replies
darkagn
315
Veteran Poster
Featured Poster
urtrivedi
276
Nearly a Posting Virtuoso
srpa01red
0
Newbie Poster
darkagn
315
Veteran Poster
Featured Poster
srpa01red
0
Newbie Poster
darkagn
315
Veteran Poster
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.