mysqldump -h yourhost -u username -p yourDatabase foo --where="user_id = 1" >dumpFile1
mysqldump -h yourhost -u username -p yourDatabase bar --where=" id in (select id from foo where user_id = 1)" >dumpFile2
mysqldump -h yourhost -u username -p yourDatabase baz --where="id in (select * from bar where id in (select id from foo where user_id = 1))" >dumpFile3
另一种选择是导出为 CSV 文件。
select * from foo where user_id = 1 INTO OUTFILE 'C:/whatever'
或类似的东西。看看手册。
更新:
没有测试,但你可以试试这个吗?
mysqldump -h yourhost -u username -p yourDatabase foo bar baz
--where="foo.user_id = 1"
--where="bar.id in (select id from foo where user_id = 1)"
--where="baz.id in (select * from bar where id in (select id from foo where user_id = 1))"
>dumpFile
更新 2:
在 mysqldump 的手册中,我看不到多个 WHERE 子句。所以恐怕你必须分多个步骤来做。