Mysql: export single row but with all dependencies

Question Mysql. I want to export one row from one table using catch: I want to collect all the rows in all other tables referenced by the source rows by foreign keys, and also refer to new rows, recursively, until I get all the rows that the source "must exist."

How can i do this?

+3
source share
1 answer

Add additional inner joins until you do this 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 
+1
source

Source: https://habr.com/ru/post/1720808/


All Articles