For each table add a parent id to match the child table.
sorty---------id-------fstart------fend
bol-----------id-------sortyid Parent For Sorty
bol_sorty-----id-------bolid-------sortyid parent for sorty and bol.
and if bol_sorty needs a parent in both.
bol_sorty-----id-------parent_bol----parentsorty--
Then--select from bol_sorty where bolid="'.$value.'" and sortyid="'.$value.'", etc.
Sample of multi Insert Query.
if(mysql_query('insert into sorty (id, fstart, fend) select "'.$id1.'", "'.$fstart.'", "'.$fend.'" from sorty where id="'.$id.'"') and mysql_query('insert into bol (id, bol, bolsorty) select "'.$bolid.'"--etc-- where id="'.$id.'" and bolid="'.$bolid.'" '))---etc.can add a third insert using---- and (mysql_query( insert into bol_sorty(etc.) select "'.$id.'",--etc. I would suggest naming field id's for each subsequent table---id, bid , sid and set the parents---pid1, pid2.