Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

MySQL - Trying to update existing prices and sizes in products table

Enthusiast ,
Mar 13, 2012 Mar 13, 2012

Hi all, I am having trouble trying to get a MySQL query to run. I am getting errors and I'm hoping somebody can advise me.

I have a table of products (ps_4products), and a table of up-to-date prices and sizes (_import_products). I am trying to replace some old content in the table ps4_products with up-to-date content in the _import_products table, but I am getting errors.

I am trying to ask the DB to match on ProductSKU and then replace the relevant info but I am getting this error:

Not unique table/alias: 'ps4_products'

I have no idea what it means though. Please advise where the error in my code is.

Here's my query:

SELECT ProductSku, COUNT(ProductSku) _import_products FROM _import_products

GROUP BY ProductSku;

UPDATE ps4_products

INNER JOIN ps4_products ON (_import_products.ProductSku = ps4_products.ProductSKU)

SET ps4_products.ProductPrice = _import_products.ProductPrice;

SET ps4_products.ProductWeight = _import_products.ProductWeight;

SET ps4_products.ProductWidth = _import_products.ProductWidth;

SET ps4_products.ProductHeight = _import_products.ProductHeight;

SET ps4_products.ProductLength = _import_products.ProductLength;

Thanks

Mat

TOPICS
Server side applications
396
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 14, 2012 Mar 14, 2012
LATEST

It's telling you that you need to use an alias for this type of operation:

UPDATE ps4_products ps4

INNER JOIN _import_products ip ON (ip.ProductSku = ps4.ProductSKU)

SET ps4.ProductPrice = ip.ProductPrice;

SET ps4.ProductWeight = ip.ProductWeight;

SET ps4.ProductWidth = ip.ProductWidth;

SET ps4.ProductHeight = ip.ProductHeight;

SET ps4.ProductLength = ip.ProductLength;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines