mysql: export single row, but with all dependencies
Mysql question. I want to export one single row from one table with a catch: I want to pull together with it all the rows in all other tables referenced from the initial row by foreign keys - and referenced from the new rows too, recursively, 开发者_如何学Gountil I get all rows that the initial one "needs to exist".
How can I do that?
Add more inner joins until you make it through your data structure
Select * from table1 t1
inner join table2 t2 on
t1.pk = t2.fk
inner join table3 t3 on
t2.pk = t3.fk
.......
where t1.pk = {pk id number} limit 0,1
精彩评论