Jump to content

how do you updated ps_products from sql with multiple queries?


Recommended Posts

I feel like an idiot for asking this but I am unable to find this anywhere and I am self learning, spent hours last night researching/googling something I would of thought would be easy to find and solve, I found how to insert values but not update values based on a conditional 'where'

 

I am trying to update all my products and the import feature on prestashop resets all my categories if I do not allocate them, so I figured I would update them via the sql phpmyadmin

 

I have 1500 products I want to update, all in spreadsheet and I just want to dump it into sql and run it, but I can only run one at a time, how to I do multiples?

 

Sample:

 

UPDATE `ps_product`

SET `ean13`=`714588001013`

WHERE `id_product`=`937`;

 

UPDATE `ps_product`

SET `ean13`=`714588002461`

WHERE `id_product`=`949`;

 

comes up with:

 

UPDATE `ps_product`

SET `ean13`='714588001013'

WHERE `id_product`='937';# MySQL returned an empty result set (i.e. zero rows).

 

UPDATE `ps_product`

SET `ean13`='714588002461'

WHERE `id_product`='949';# 1 row affected.

 

or SQL syntax error

or

#1054 - Unknown column '1093' in 'where clause'

Link to comment
Share on other sites

found this at – http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=126987

How do I update multiple fields with single update statement using subqueries?

 

 

Makes no sense to me, would love to figure this out

 

The first example is an UPDATE statment:
UPDATE tgt
SET ( tgt.x, tgt.y ) =
( SELECT src.x, src.y
   FROM src
  WHERE src.id = tgt.id
)
WHERE EXISTS
( SELECT src.x, src.y
   FROM src
  WHERE src.id = tgt.id
)
/2 rows updated.
select * from tgt;	    ID		  X		  Y
---------- ---------- ----------
	 1		  1		  1
	 2		  5		  5
	 3		 10		 10

Link to comment
Share on other sites

×
×
  • Create New...