开发者

How do I add data to particular column in exisiting table?

How can I insert data to only one column in an existing table?

I dont want other column get disturbe开发者_开发知识库d or altered..


I think you're looking for an update query:

UPDATE
  table_name
SET
  column = 'value';

That will only "insert" data into a single column while leaving everything else undisturbed.

If you want to update from the results of another table, you can also do joins:

UPDATE
  table_name
    INNER JOIN source_table ON
      table_name.some_id = source_table.some_id
SET
  table_name.column = source_table.column;

Hope that helps. You might want to try clarifying the question with some more information.


If you mean "insert" as in "update" then

# to a fixed value
update tbl set col = "abc"
# WHERE <some condition>  # optionally identify which record

# add to existing value
update tbl set col = concat(col, "abc")   # add "abc" to the end of the current value
# WHERE <some condition>  # optionally identify which record
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜