开发者

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

开发者 https://www.devze.com 2023-02-05 15:40 出处:网络
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:

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

精彩评论

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