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

how to update a row with arithmetic expression in Sqlite android

What I want is to add and remove new value to the existing value in Sqlite android. What I've read from the android documentation is this method, but it's not working in my case cause it's removing the existing value with the new one that's being…
Ari
  • 37
  • 5
2
votes
4 answers

Cannot insert the value NULL into column (UPDATE with CASE, SQL Server)

I would like to update a table using a CASE expression, but I get an error, however I do not SET NULL values: Cannot insert the value NULL into column 'Column2', table 'Table1'; column does not allow nulls. UPDATE fails. My code: UPDATE [Table…
JeyKo
  • 63
  • 10
2
votes
3 answers

Updating records missing from clause

With this query, I'm getting an error ERROR: missing FROM-clause entry for table "inv" LINE 1: update stock_picking set invoice_status = inv.date_invoice My goal is to set stock_picking posting_date to inv.date_invoice if it meets all conditions,…
Chaban33
  • 1,362
  • 11
  • 38
2
votes
1 answer

Update row with maxdate where id from select and maxdate from select is given

I have a select statement that returns a set of ids and a maxdate. Now, I want to update the performance_date in the invoices table with the given maxdate where the given invoices ids. Select invoices.id, max(invoicepositions.performance_date) as…
DS87
  • 536
  • 3
  • 9
  • 29
2
votes
2 answers

How to set resulted Data in query while updating in mysql

My question related to MySQL , how to set data which is result from where condition for example , in tbl_user there is status column now i want to update status column with starting letter current existing word in status column existing…
sameiksha
  • 25
  • 5
2
votes
3 answers

SQL Server - Inserting Multiple Values Into Column

I'm trying to update my pizza so it will allow more than one topping. I am receiving the error Cannot insert duplicate key row in object 'dbo.PizzaToppings' with unique index 'FK_Pizza'. The duplicate key value is (3). when trying to add more than…
Cameron Cole
  • 410
  • 1
  • 4
  • 20
2
votes
1 answer

Allowed duplicate record if data not exist in different column

I have 2 column name location_id and district_id. location_id record can be duplicated if existing location_id and district_id record does not match. The table below will explain it. Notice the duplicate record of location_id and district_id. This…
sg552
  • 1,521
  • 6
  • 32
  • 59
2
votes
1 answer

Append between two html tags in postgres table

Postgres table with name postgrestable: ID NAME HTML 1 FRONT test How can i create a update query that appends a new between the tags. The table should be…
Mr ASD
  • 103
  • 1
  • 1
  • 8
2
votes
1 answer

Generate UPDATE SQL statements from a csv file

Example: User ID, Last Name, First Name, Start Date, End Date 001, Pudding , Chocolate , 10/01/2018, 10/30/2018 002, Cake , Carrot , 10/06/2018, 11/07/2018 003, Pie , Apple , 10/03/2018, 11/01/2018 And let's say I…
Hana
  • 85
  • 1
  • 9
2
votes
5 answers

Returning how many rows changed while IF statement is used?

I am running some update statements in SQL and I want to return to an Audit table how many rows have been affected. Now I understand (and have seen examples) that a @@ROWCOUNT can be used to do this. The problem is I'm using an update statement with…
JimmyPop13
  • 307
  • 1
  • 13
2
votes
2 answers

Update a field in one table with a minimum value in a field in a different table

I have two tables that both have a field named PostDate. Both tables also have a field called LoadID. In the first table there is one record for each LoadID. In the second table there are multiple records for each LoadID and each record has a…
John Lee
  • 317
  • 6
  • 14
2
votes
2 answers

Add contents of one column into another without overwriting

I can copy the contents of one column to another using the sql UPDATE easily. But I need to do it without deleting the content already there, so in essence I want to append a column to another without overwriting the other's original content. I have…
Kilisi
  • 402
  • 11
  • 33
2
votes
1 answer

UPDATE records from SELECT using a case statement. (mysql)

I am trying to update a collection of records using a case statement but I get: error: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM( SELECT…
2
votes
1 answer

Trying to overwrite sqlite database in iPhone app update

Unlike most sqlite apps where developers don't want to overwrite data in a sqlite database, I'm trying to enable an app to overwrite all data with future updates. The sqlite database will have the exact same name and have the same tables, I just…
Benjamin
  • 103
  • 2
  • 10
2
votes
2 answers

Format date in DataGridView column in custom format

I have a DataGridView where the user inserts data about different products. One of the columns holds data for the date when the item expires. I was told to make it as easy and fast for the user to type this date, so I have to make the date format…
Gabriel Stancu
  • 940
  • 2
  • 13
  • 26