开发者

SQL Update: Append data to a cell

I would like to create an SQL query which updates said columns with new 开发者_开发知识库data but also data from that particular row which is being update. If you could imagine, "prepending" new data to a cell but that keeps that same data in that cell. For example, I want to add the follow, "some_text", to a cell which already has "other_text" to make: "some_textothertext". However I want to set "some_text" to a variable in PHP.

I have no idea on how to approach or complete this and a word of guidance is very much appreciated, thank you. :3


I think the MySQL CONCAT function is what you're looking for.

UPDATE
    some_table
SET
    some_text = CONCAT(some_text, '<<echo php variable here>>')
WHERE
    id = 3


You can do this by following this steps:

  1. Retrieve data from current wanted cell.
  2. Append your data to the
  3. retrieved cell in variable. Now, update your cell.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜