Jump to content

Mysql query find and replace CSV ( Replace ID with reference )


zahiras

Recommended Posts

Hello,
I'am looking for a way to export the data I need in the CSV file, for data import into another store.
With this query and the table (ac.id_product_2) I am getting the product accessories ID, but for import I have to get the product accessories reference (because in another store, the same product has different ID but the same reference)

Is there a way to replace the accessories ID, with product reference?
It is my first Mysql query, I don't know if it is possible. :)
 
SELECT pl.name, p.reference, p.mcompleted, pl.description_short, pl.meta_title, pl.link_rewrite, GROUP_CONCAT(DISTINCT ac.id_product_2)
FROM ps_product p
INNER JOIN ps_product_lang pl ON (p.id_product = pl.id_product)
INNER JOIN ps_stock_available s ON (p.id_product = s.id_product)
INNER JOIN ps_accessory ac ON (ac.id_product_1 = p.id_product)
WHERE pl.id_lang = 2
AND p.active = 1
AND s.quantity > 0
AND p.id_product > 35000
AND p.mcompleted = 1
GROUP BY p.id_product
 
Best regards
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...