MySQL On Duplicate Key Update?

You probably don't want this line: UNIQUE KEY `Quantity` (`Quantity`) That creates a unique constraint on the quantity field, which is why your second insert is failing. I can't think of any reason why you would want that P.S. If you remove that line, make sure to remove the comma (,) from the previous line.

You probably don't want this line: UNIQUE KEY `Quantity` (`Quantity`) That creates a unique constraint on the quantity field, which is why your second insert is failing. I can't think of any reason why you would want that. P.S.If you remove that line, make sure to remove the comma (,) from the previous line.

That is extremely obvious – RPM Jun 4 at 1:36 @RPM You would be surprised what's not obvious to many people. – dkamins Jun 4 at 1:38 Or use remove the UNIQUE part if you still want to do fast lookups by Quantity. – Joshua Martell Jun 4 at 2:37.

This should work and is a little more elegant.

I believe you're looking for the mysql function concat() ( docs ) The SQL would look something like this: INSERT INTO table (prod_name) VALUES ('abc') ON DUPLICATE KEY UPDATE prod_name=concat(prod_name,',','abc').

I believe you're looking for the mysql function concat() (docs). The SQL would look something like this: INSERT INTO table (prod_name) VALUES ('abc') ON DUPLICATE KEY UPDATE prod_name=concat(prod_name,',','abc').

Use $sql= " INSERT INTO table (prod_name) VALUES ($x) ON DUPLICATE KEY UPDATE prod_name='prod_name+$x' "; Note: prod_name should be UNIQUE index or PRIMARY KEY edit try this $sql= " INSERT INTO table (prod_name) VALUES ($x) "; $sql . = is_numeric($x)? " ON DUPLICATE KEY UPDATE prod_name=prod_name+$x " : " ON DUPLICATE KEY UPDATE prod_name=CONCAT_WS(',',prod_name, $x).

Thanks for your answer, however, it doesn't work. For product name it can also contain digits only. When there are only digits, it sum them up and it also does not put comma between two names – Tweety Feb 25 at 5:39 put the condition on $x and make two different query – diEcho Feb 25 at 5:43 I am sorry, but could you please provide example what do you mean by condition on $x – Tweety Feb 25 at 5:46.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions