My mysql table is : P开发者_运维百科roduct (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;
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 |
+-----------------+
精彩评论