如何通过连接多列文本值来更新列文本值?

How to update column text value with concatenation of multiple columns text values?

例如我的 table 结构就像

id(int, auto_increment), 
first_name(text), 
last_name(text), 
address(text), 
merged_content(text)

我有数千行已经填充了 first_namelast_nameaddress 条目。 我想更新 merged_content 中的串联文本。我知道如何在 PHP 中执行此操作,但更新数千条记录(约 30K)非常耗时。

所以,我希望 如果这样的事情可以直接在 MySql 中实现 -

Update table_x set merged_content="<p>" + first_name + " " + last_name + "</p><p><b>Address -</b> " + address + "</p>"

显然上面的查询是错误的,没有工作,但我什至找不到其他任何我可以尝试的东西。

sql 中的串联运算符不是 +。这是||

将所有 + 替换为 || 以使查询有效

Mysql 有一个名为 concat 的内置函数,您可以使用它,如

Update table_x 
set 
merged_content=
concat('<p>',first_name,' ',last_name,'</p><p><b>Address -</b> ',address,'</p>');