How do I update an entire table column
source link: https://www.codesd.com/item/how-do-i-update-an-entire-table-column.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How do I update an entire table column
I have a Micropost
table with columns user_id
and sender_id
(both integers). I've just added the sender_id
column and by default it's value is nil for existing table rows. As a one time thing I want all of the user_id
values to be copied and pasted into the sender_id
column for the rows already existing. some sort of migration required?
You can do this from rails console.
Micropost.update_all("sender_id = user_id")
Related Articles
How do I update my MySQL table column with a unique random sequence number?
SQL update statement - Attempt to update the entire table error
Why does this SQL update the entire table?
How to ensure that it is possible to update a database table column only in one way?
How to hide or display the table column created using javascript data?
How can you update to a table in another database using postgres dblink?
How to iterate through an HTML table column and enter values in a Javascript matrix using JQuery
HTML: how to increase the width of table columns when the table is inside a div with a fixed width
How is a CSS display & ldquo; Table-column & rdquo; Held to work?
Update the third table column according to other 2 tables
How to Manually Update the Data Table with New JSON Data
How to save or retrieve a table column using Hibernate
How do I update a model (table) of a different controller (or model)
How to get values from a table column, concatenate them with a string and insert them into another table?
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK