Updating a field in mysql

I want to update this column with value "accepted",but iam unable to do so.

In one of our larger Rails apps the sheer volume of data we process means we’ve had to rely more and more on direct SQL queries, denormalised tables and summary tables to speed things up.

As with most things in life, this is best demonstrated through an example.

The following SQL statement is designed to change the product description column of a row in a table where the prod_id column is equal to 12134.

I was wrongly under the impression that the updates took place in one mass-assignment after the entire query had been interpreted by My SQL.

But they’re not: the assignments happen in the order they appear in the query.

When updating data in a table it is possible to either update specific rows, or to update all the rows in a table.

These tasks are achieving using the SQL UPDATE statement combined with the SET and WHERE keywords.

updating a field in mysql-22updating a field in mysql-42updating a field in mysql-73

In certain situations the result of the statement remains consistent throughout the update, it also cleans up the query making it a little easier on the eyes.It is also possible to update multiple columns with a single UPDATE statement.This requires the use of multiple column = value expressions in UPDATE statement.To give you an example, this query won’t produce the expected result: . Keeping in mind the importance of the order in which fields are updated, conditions that involve multiple fields are a little trickier.For example, a slightly different summary table could look like this: This summary table tracks the most recent event for the most recent session for a user.

Leave a Reply