Let's say there is a production
I don't think there's an easy way to do this all at once. The only way to subset the data is with the
-w option, but it will try to use the same
WHERE condition for all tables. You could do it in two steps:
mysqldump -w 'id < 1000' dbname mastertable > mastertable.sql mysqldump -w 'master_id < 1000' dbname child1 child2 child3 ... > children.sql
This assumes all the child tables use the same name for their foreign key.
You can simplify the second command to:
mysqldump --ignore-table=dbname.mastertable -w 'master_id < 1000' dbname > children.sql
if all the other tables in the database are children.