dilp, примерный запрос select * from category join sklad join mag on category.id = sklad.catid, sklad.id = mag.sklid