Code:
-- get the rest of the product info
delete from products;
insert into
products
(
products_id,
products_type,
products_quantity,
products_model,
products_price,
products_status,
products_tax_class_id,
products_price_sorter,
master_categories_id
)
(select
productID,
1,
1,
0,
Price - (Price/11),
1,
1,
Price,
1
from
OTHER_DB.OTHER_TABLE);
-- get the path for the product images
UPDATE products SET products_image = ( SELECT filename
FROM OTHER_DB.OTHER_TABLE
WHERE productID = products.products_id
LIMIT 1) ;
-- get the product id, name and description
delete from products_description;
insert into
products_description
(
products_id,
language_id,
products_name,
products_description
)
(select
productID,
1,
name,
description
from
OTHER_DB.OTHER_TABLE);
-- get the category ids (ignoring the root category)
delete from categories;
insert into
categories
(
categories_id,
categories_image,
parent_id,
sort_order,
date_added,
last_modified,
categories_status
)
(select
categoryID,
0,
parent,
0,
NULL,
NULL,
1
from
OTHER_DB.OTHER_TABLE
where
categoryID not in (1));
-- get the category ids, parent ids, name and description
delete from categories_description;
insert into
categories_description
(
categories_id,
language_id,
categories_name,
categories_description
)
(select
categoryID,
1,
name,
description
from
OTHER_DB.OTHER_TABLE
where
categoryID not in (1));
-- get the product and category ids
delete from products_to_categories;
insert into
products_to_categories
(
products_id,
categories_id
)
(select
productID ,
categoryID
from
OTHER_DB.OTHER_TABLE
where
categoryID not in (1));
-- commit all the above changes to the database
commit;
I thought I probably shouldnt be populating the master categories ID field - but ive tried my query both with and without it and its still the same result.