mysql - SQL - Updating table with informaton from another table -


I am trying to run an update on the espap of my companies, but trying to work out the right SQL Used to be. Command to do the following:

I have three tables:

  Products ------------ pId pSearchParams ProductCategories ----- - ------------ pcProductId // products.pId pcCategoryId // categories.catId Categories ---------- catId catName  

me To update the pSearchParams field in the Products table with information from catName field in the categories table.

The only way I can do this is to link the products table with the ProductCags table, as ProductCags is the table The only way I can establish a link between the products table and categories tables.

The problem is that there is a possibility of having the same information on multiple lines in productcategories table, pcProd UctId , same pcCategoryId (I.e. products can be in many categories)

To update all the pSearchParams fields in products , enter a UPDATE < / Code> Need to run the statement> Table with related category names, allow for multiple category names.

If I need to provide more information please let me know Thank you.

PC. PcProductId) include ASCON (PCPCCIRII = CCADID) SET p.pSearchParams = c.catName

update

  as UPDATE products P SET p.pSearchParams = (SELECT GROUP_CONCAT (c.catName SEPARATOR '') Through product catalogs as PC janetate categories ASC (PCPCACIRI = C CATID) where PPCP DentID = PPID Group by PCPP Product ID)  

Comments