带有CONCATENE字段的SQL更新

时间:2017-03-30 01:23:23

标签: sql concatenation

Hy Everyone,

我有下表

mysql> select * from recipes;
+------+-------+
| id   | direct|
+------+-------+
|    1 | max   |
|    2 | linda |
|    3 | sam   |
|    4 | henry |
+------+-------+

但是需要更新所有直接字段并将{{ }}放在字段的开头和结尾。

+------+-----------+
| id   | direct    |
+------+-----------+
|    1 | {{max}}   |
|    2 | {{linda}} |
|    3 | {{sam}}   |
|    4 | {{henry}} |
+------+-----------+

我该怎么做?

我尝试了UPDATE recipes SET direct = '{"step": [{ "description": "'+direct+'","image": ""}]}',但它对我不起作用。

请帮帮我!!!

2 个答案:

答案 0 :(得分:0)

以下是一种适用于任何数据库的方法:

UPDATE recipes
    SET direct = REPLACE('{{x}}', 'x', direct);

答案 1 :(得分:0)

尝试使用concat

# Dataset used:
X = np.array([
    [0.0, 0.0], [0.1, 0.0], [0.2, 0.0], [0.2, 0.1], [0.3, 0.1], [0.4, 0.1],
    [0.4, 0.2], [0.5, 0.2], [0.5, 0.3], [0.6, 0.3], [0.7, 0.3], [0.8, 0.3],
    [0.9, 0.3], [0.9, 0.4], [0.9, 0.5], [0.9, 0.5], [0.9, 0.6], [0.9, 0.7],
    [0.9, 0.7], [0.9, 0.8], [0.8, 0.8], [0.8, 0.9], [0.7, 0.9], [0.6, 0.9],
    [0.5, 0.9], [0.4, 0.9], [0.4, 0.8], [0.3, 0.8], [0.3, 0.7], [0.2, 0.7],
    [0.2, 0.6], [0.2, 0.5], [0.2, 0.4]
])