0

My mysql table is : Product (name,price,metaDescription)

I want to write an SQL UPDATE to Set my metaDescription name+' is only just for'+metaDescription

I tried this but it didn't work

UPDATE 
  product 
SET 
  metaDescription=name+' is just for'+price;

1 Answer 1

1

You should use the concat function:

update product
set metaDescription = concat(name, ' is just for ', price);

MySQL should automatically convert price to a string type for you.

MySQL is trying to convert your strings to numbers (and silently failing) when you use +:

mysql> select 'this' + 'that';
+-----------------+
| 'this' + 'that' |
+-----------------+
|               0 |
+-----------------+
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.