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
1 answer

Updating data to integrate it in my datawarehouse

I received sales data from a client to integrate it into his datawarehouse. Normally there are two columns to define a sales row - num_transcation and num_line_transaction. But I received a lot of rows with the same num_transcation and…
2
votes
1 answer

How to concatenate two strings in SQL statement?

The problem I have a SQL database named "matches" with a textfield named "events". In this event there is some data and I want to add a string to this data. For example: the existing data is "Goal: Aguero" and I want to add, with a SQL statement,…
T. Hægh
  • 109
  • 1
  • 9
2
votes
2 answers

SQL UPDATE isn't updating the database, is there something wrong with my SQL statement?

This is my first attempt at a 'real' C# program. It takes a specified directory, extracts the file name (without extension) and writes them to an SQL database. This data is then read back into an array and passed into the below 'foreach' loop. The…
2
votes
2 answers

Pandas Update dataframe with join on common column

I have df1 (key_col, cola, colb, colc) and df2(key_col, colz) I want to do the SQL equivalent of: UPDATE df1 SET df1.colc = df2.colz WHERE df1.key = df2.key I've tried various incarnations of merge and join without success. Not looking for loops…
RookieCookie
  • 155
  • 8
2
votes
2 answers

UPDATE the Columns of the Rows of the SELECT output

TABLE fruit name family ordered ordered_on apple tree false null banana tree false null mango tree false null TABLE basket name family …
MrKarma4u
  • 144
  • 2
  • 13
2
votes
4 answers

How To: Insert into column where the value is on another table

Summarize the Problem: I want to write a booking code. I had a little problem, that I wanted to insert a value into the booked table that is in another table called house_info. The detail of booked & house_info database is below: Booked Table …
Faj
  • 75
  • 9
2
votes
3 answers

Speeding up an UPDATE in MySQL

I need to update about 6M rows in a table that has about 21M rows, and that is taking about 1 hour. This is part of a data migration and I have full control over the database. Nobody else is using it, and I can stress it as much as I wish, I want to…
Xavier Noria
  • 1,640
  • 1
  • 8
  • 10
2
votes
2 answers

how to update unique default option in one sql

i have table like this ----------------------- id | name | is_default| ------------------------ 1 | a | 1 | 2 | a | 0 | 3 | a | 0 | 4 | a | 0 | ----------------------- now i want to change line 2(id…
serapme
  • 21
  • 3
2
votes
2 answers

Update fields with data from a second table

I have a database in PostgreSQL and I'm having some problems updating some values, let me explain. I have three tables. Table A: id | itemID | Value Table B: Name | Value Table C: itemID | Name I need to update the value field on…
2
votes
1 answer

Update query with order by

I am trying to update one column based on another column short. I am using order by, but while using select top(10000) my incremental number going 4000 series but I need from 101, but initially I declare int 100 DECLARE @IncrementValue int SET…
sathish
  • 19
  • 4
2
votes
1 answer

1287 user variables within expressions is deprecated - query rewrite

I am using this query to update rows and get updated IDs. But after mysql update I am getting this warning: "1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET…
Caldur
  • 135
  • 10
2
votes
1 answer

How does PostgreSQL interpret these two join statements?

I have a question between two very similar PostgreSQL statements: UPDATE classes SET year = 1 FROM professors WHERE (professors.class = classes.class) AND professors.name = 'Smith'` This one seems to inner join the classes table and the professors…
paulinho
  • 292
  • 2
  • 13
2
votes
2 answers

How to update a column only once in a SQL Server Agent job that runs every 5 minutes

I want to run this code only once in an agent job that gets hit every 5 minutes: UPDATE mytable SET text_column = (CONCAT('Added text - ', text_column)) WHERE status IN ('status1', 'status2', 'status3') AND other_criteria IN ('other_criteria1',…
2
votes
1 answer

what is flow of this zend update statement

I know that this statement updates the record in the zend framework. But I want to understand the complete flow of this statement. Statement is $request->update($data,$request->getAdapter()->quoteInto('id =…
Awais Qarni
  • 17,492
  • 24
  • 75
  • 137
2
votes
1 answer

Select for update query returns cardinality violation

We are running this query in Postgres 9.6.10 in a Google managed cloud DB: WITH update AS (UPDATE cart SET loyalty = loyalty || jsonb_insert('{}', '{coupon}', loyalty#>'{scan_coupon}' || $1) WHERE id = (SELECT id FROM cart WHERE id = $2 AND…