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

MySQL Update Colum Based On Other Column

I have this table : table_a +----+--------+ | id | status | +----+--------+ | 10 | ERROR | +----+--------+ and I also have this table : table_b +------------+----------------+ | trading_id | trading_status | +------------+----------------+ | …
Saint Robson
  • 5,475
  • 18
  • 71
  • 118
2
votes
1 answer

Dapper Execute function that can call PostgreSQL function and return rows affected from update or insert

I am trying to create a postgresql function that does an update. I want to get the rows affected. I know this can be done by using GET DIAGNOSTICS rows_affected = ROW_COUNT. But I am trying to use the Dapper Execute function which can return rows…
Joe M
  • 3,060
  • 3
  • 40
  • 63
2
votes
2 answers

Get error when update from other table: ORA-30926: unable to get a stable set of rows in the source tables

I have a query to Update a table with a Select from another table, This is my query: MERGE INTO tb1 USING tb2 ON ( tb1.id = tb2.id AND tb2.name IS NOT NULL AND tb2.val = ( SELECT MAX(val) …
2
votes
1 answer

Update Statement Retrieves Incorrect Values

I have the following two tables PARTNERS CREATE TABLE [dbo].[Partners]( [ID] [bigint] IDENTITY(1,1) NOT NULL, [PartnerID] [varchar](50) NOT NULL, [PartnerName] [nvarchar](200) NOT NULL, [Active] [bit] NOT NULL, [InactiveDate] [datetime]…
EllieK
  • 259
  • 4
  • 14
2
votes
2 answers

Join two tables in Postgresql while keeping non-matching rows

I am trying to join a spatial table with a non-spatial table in Postgresql using the PostGIS extension. spatial_table: geom | attribute1 | Key | foobar | foobar | 1 | foobar | foobar | 2 | foobar | foobar | 3 | foobar | foobar …
Jscore
  • 375
  • 1
  • 5
  • 14
2
votes
1 answer

Xquery to update value of a node of a xml stored in a column of a table

i use DB2 express-c edition v9.1 database management system. name of the table: student name of the column: course xml in the column: **101** **0** **102** …
Ajish
  • 21
  • 2
2
votes
1 answer

Can I get the resulting message from an UPDATE in Oracle?

When I run an UPDATE statement in Oracle, is there a way to catch the returning message from the update that is displayed in the console (should be something like "15 rows updated" for example)? If not, is there a way to catch the number of rows…
Rexam
  • 823
  • 4
  • 23
  • 42
2
votes
1 answer

SQL UPDATE using unusual syntax

I came across this stored procedure today and I'm confused with the syntax on it. It is doing an UPDATE and the query looks like this: DECLARE @TransactionStatus tinyint = 1, @RedeemedAmount decimal(18,2) = 0, @PromotionCodeAmount…
Docker John
  • 100
  • 7
2
votes
2 answers

Updating BLOB from MySQL Workbench

I have a problem with one SQL statement. I am trying to update something in a table which is a Blob field with a pdf. And it's not working. UPDATE employees SET resume = LOAD_FILE('C:\Users\gaby\Desktop\sample_resume.pdf') WHERE id = 1; If I use…
user9608350
2
votes
2 answers

Update a column when price column of other table is modified. Triggers. Nested tables. SQL Server

In my database I have about 10 tables connected in one central table (Mobile). This table (Mobile) has a column called price which is the sum of the prices of all other nested tables. I would like that when price of another table (like Battery,…
JuMoGar
  • 1,740
  • 2
  • 19
  • 46
2
votes
3 answers

Update statement taking more than 24 hours for updating 32k rows

Below is the update statement that I am running for 32k times and it is taking more than 15 hours and running. I have to update the value in table 2 for 32k different M_DISPLAY VALUES. UPDATE TABLE_2 T2 SET T2.M_VALUE = 'COL_ANC' WHERE EXISTS…
LearningCpp
  • 972
  • 12
  • 29
2
votes
2 answers

MYSQL use of CONCAT and SUBSTRING with http and https URLS in database

This question revolves around using CONCAT and SUBSTRINGS to UPDATE the content in mysql TABLE If I have a link stored in a mysql database that consists of…
Snp
  • 21
  • 2
2
votes
1 answer

Python SQLite: Update Statement TypeError: function takes exactly 2 arguments (1 given)

For some reason I keep getting a findSenGroup = cur.executemany("UPDATE SEN_Table SET SenNumber = " + senNumStr + " WHERE FormName='" + nameGroup + "'") TypeError: function takes exactly 2 arguments (1 given) error with this update…
Adam Azam
  • 93
  • 1
  • 1
  • 7
2
votes
1 answer

Nested case in Mysql

I need to write a SQL statement if TC is greater than 1 return 500 if TC is greater than .5 return 200 if TC is greater than .25 return 100 if TC is less than .25 return 50. I know it's a nested case, using MySQL EDIT: If table two has…
Merlin
  • 24,552
  • 41
  • 131
  • 206
2
votes
1 answer

Trouble with Update-Set-From syntax in Oracle

I am trying to execute a simple SQL update-set-from statement in Oracle, which looks like the one below: update table1 t1 set t1.col1=t2.col1 from (select distinct t1.col1 from table1 t1 where t1.col2='xxx') as t2 where t1.col1='yyy'; I haven't…
lebowski
  • 1,031
  • 2
  • 20
  • 37