Questions tagged [sql-update]

An SQL UPDATE statement is used to change existing rows in a table.

An SQL UPDATE statement is used to change existing rows in a table.

The basic syntax is:

UPDATE table 
SET 
    Column1 = 'x',
    Column2 = 'y'
WHERE id=1

Tagging Recommendation

This tag should be used for general SQL programming language questions, in addition to tags for specific products. For example, questions about Microsoft SQL Server should use the tag, while questions regarding MySQL should use the tag. Tagging by product (including version, e.g , ) is the easiest way to know what functionality is available for the task at hand.

References

12009 questions
2
votes
2 answers

Create function in postgresql to update column values from a table with preferred values and aliases

I want to create a function that will update a column of type varchar to a preferred string that is referenced in the column of another table to help me clean this column more iteratively. CREATE TABLE big_table ( mn_uid NUMERIC PRIMARY KEY, …
nmsindt
  • 21
  • 1
  • 2
2
votes
2 answers

Database isn't updating

I am trying to write some data into a .MDF database that has only one table, and it's not updating after I execute this part of the code: DatabaseDataSet.MyTableRow newRow; newRow = databaseDataSet.MyTable.NewMyTableRow(); …
deckard cain
  • 497
  • 10
  • 24
2
votes
0 answers

wrong save of float value PHP SQL

I have a problem with update or save of float value in my DB from PHP/Laravel. Example: budget 166.0 -> FLOAT(5,1) in DB subscription_fee 7.5 -> FLOAT(5,1) in DB This My code for operations: foreach ($teams_ctrl as $team_ctrl) { …
MarSic
  • 33
  • 3
2
votes
0 answers

Update record based on rowversion value?

I have recently implemented SQL rowversion to prevent concurrency issues in my system. I use rowversion in where clause when updating single rows in the tables. So far I have tested and seems like a good solution. Now I'm looking for an easy way to…
espresso_coffee
  • 5,980
  • 11
  • 83
  • 193
2
votes
1 answer

Postgresql UPDATE LEFT JOIN

So, I have the following code that updates a language string table, based on an id, and a language code. If I perform a SELECT using the same from expression, it selects just one row. If I do update, it updates all rows. Where am I going wrong with…
whitelined
  • 310
  • 4
  • 13
2
votes
1 answer

Getting the Error message when I tried to update multiple column in oracle 11 g

I am new to Oracle 11g SQL command line. I am trying to update multiple columns with the one query. I ran this command to update User_information table. update user_information set email = 'new@email.com', set name = 'new_name' where username =…
2
votes
2 answers

Oracle SQL CURSOR Update with Join and Commit

i want to update a table with the value of another table. But: I need a commit after every 50000 rows. I don't want to discuss why and I know the tip to create a new table instead of update, but this is not an option. I need only help with the…
Mirjam
  • 21
  • 2
2
votes
1 answer

PostgreSQL update not working as expected

With 20+ years of experience with MS Access and SQL Server, I'm not a novice with respect to SQL, but I am new to PostgreSQL and I have encountered an issue that makes me feel like a complete noob. I have a simple UPDATE query in which I want to…
CNIDog
  • 374
  • 3
  • 18
2
votes
1 answer

Mysql error 1064 while changing password

While trying to change mysql password by following steps given in this solution, i got the following error- mysql> UPDATE mysql.user SET authentication_string = PASSWORD('letsrock') WHERE User = 'root' AND Host = 'localhost'; ERROR 1064 (42000):…
monster
  • 808
  • 10
  • 23
2
votes
2 answers

Update JSONB column data from other columns in same table

In Postgres 9.5 I want to update a column with data from other columns in the same table. The issue is with "" signs because inside the JSON string it is not allowing to read data from actual column: CREATE TABLE sample_table( id bigint ,…
Dmitry
  • 165
  • 1
  • 9
2
votes
1 answer

Update all rows affected by a group by

I have the following query using PostgreSql : SELECT SUM(table.a) FROM table GROUP BY table.b HAVING SUM(table.a) > x; And now I need to update a column in all rows affected by the precedent query. I tried the following solution : UPDATE table…
Vetouz
  • 159
  • 3
  • 19
2
votes
2 answers

SQL Server Update Latest Records Only in a Group

I'm using SQL Server 2008 R2 and I have 2 tables Product and Product_Master. I want to update only the latest version of records in Product_Master from Product table leaving earlier versions as it is. CREATE TABLE [dbo].[Product] ( [ProdId]…
raajesh
  • 115
  • 1
  • 2
  • 5
2
votes
2 answers

UPDATE by matching ROW_NUMBER with another table?

This can be done fine in SQL Server (whereas we can use FROM clause in UPDATE statement). But I'm fairly new to Oracle SQL. The scenario is simple like this. I have 2 tables (having the same number of rows). Now I need to update one column of this…
Hopeless
  • 4,397
  • 5
  • 37
  • 64
2
votes
2 answers

Issues using UPDATE statement in MySQL

I'm trying to update a column using PHP and MySQL. Basically I have a database of adults and a database of children. When I child is added I want to add the ID(s) of the children to their respective adults. When I child is added I grab the ID for…
Dan
  • 2,304
  • 6
  • 42
  • 69
2
votes
1 answer

When using the SELECT INTO a #TEMP table,are the results logged to the transaction log?

I have been able to optimize large table UPDATES with JOINS by separating the UPDATE and JOIN into two queries. I know the UPDATES are logged, but by creating a temporary table I have greatly reduced my UPDATE time by joining with the temporary…
Clark Vera
  • 183
  • 1
  • 7