aron n
aron n

Reputation: 597

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 disturbed or altered..

Upvotes: 2

Views: 35365

Answers (2)

jerhinesmith
jerhinesmith

Reputation: 15492

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.

Upvotes: 5

RichardTheKiwi
RichardTheKiwi

Reputation: 107706

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

Upvotes: 2

Related Questions