INSERT INTO sblt_stock_locations (location_name) (SELECT location FROM sblt_items WHERE NOT EXISTS (select location from sblt_stock_locations where location_name = location)); INSERT INTO sblt_item_quantities (item_id, location_id, quantity) (SELECT item_id, location_id, quantity FROM sblt_items, sblt_stock_locations where sblt_items.location = sblt_stock_locations.location_name);