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

SQL query executes successfully but no change is made

I have a table with a DateTime column Move_Date. The dates are correct, but the time portion is zeroed out so I tried to replace the zeroed columns with the correct time. my query is as follows: update TableA set Move_Date = replace(Move_Date,…
2
votes
1 answer

Update table using select query

I'm trying to update desiredValue from updatedTable table if only the statements from where clause is satisfied, otherwise it should not set a value. Is below a correct statement? update updatedTable si set desiredValue = select desiredValue …
yed2393
  • 262
  • 1
  • 12
2
votes
3 answers

How to convert mysql query to oracle ( using UPDATE and INNER JOIN 2 times with 3 tables)

I have the following MySQL query: UPDATE spot ST INNER JOIN tag_mapping_spot c ON c.spot_id = ST.spot_id INNER JOIN def_table b ON b.tag_id = c.tag_id SET ST.spot_name = b.tag_ja Recently I move to oracle and want to convert this query to oracle…
Hoàng Việt
  • 174
  • 1
  • 14
2
votes
3 answers

update oracle date column with different date values

When updating the old dates to the new dates, I am getting SQL Error: ORA-00932: inconsistent datatypes: expected DATE got CHAR 00932. 00000 - "inconsistent datatypes: expected %s got %s" UPDATE test SET date1 = CASE date1 WHEN…
Mona
  • 273
  • 1
  • 2
  • 13
2
votes
2 answers

UPDATE column using a window function

I am using PostgreSQL 9.3 I have a table named cat with the three following columns of interest: ID, SOURCE, TIME ID and TIME values are unique (i.e. no duplicates) but several rows have the same SOURCE value I would like to update each value of the…
2
votes
2 answers

Oracle - update record and return updated date in same query

I'm using Java 8 with Spring's JdbcTemplate and Oracle 12.1, I want to update record and get the exact time record was updated jdbcTemplate.update(UPDATE_SQL, null); Currently it returns (int) the number of rows affected, but I want the exact…
Ori Marko
  • 56,308
  • 23
  • 131
  • 233
2
votes
2 answers

Multiple UPDATE ... FROM same row is not working

I'm trying to do multiple update, but it works only for the first row. I have table "users" with 2 records: create table users ( uid serial not null constraint users_pkey primary key, balance …
Yuri
  • 21
  • 2
2
votes
1 answer

Update a text column that contains a newline character '\n'

I'm encountering weird behaviour of PostgreSQL where I try to run the following query update posts set content = replace(content, '\n', '
') where content is not null; and it's not doing anything to the data in the database. I **tried…
Codin Moldovanu
  • 90
  • 2
  • 10
2
votes
2 answers

Update\Insert data from grafana to mysql

Is is possible to update data or insert data from grafana to mysql. I have a requirement to insert/update information in mysql using a UI. Now I am already using grafana so wanted to know if there is any way we can use grafana to update or insert…
Nipun
  • 4,119
  • 5
  • 47
  • 83
2
votes
3 answers

Room DB Upgrade need to write full insert query

Hi I am developing an android app and I am using room DB and I have created one table and now I want to add another table I need to write a migration for that and in-migration I need to write full SQL queries for the new table assume I have more…
2
votes
1 answer

Updating SQL table from XML

I am using InfoPath 2007 to send out a survey (it is not connected to SharePoint or a DataBase). The file I will get back is an XML file. Every place there is an answer block, it has its own unique id (aka field name). Now, I have a SQL Server…
2
votes
1 answer

Update a PostgreSql table using a Python variable

I have the following table in my PostgreSql database with 1 row of data. I want to update the value in the "diagnosis" column (currently 3) to another number. My python code is below: Based on my code below, the "diagnosis" column should equal…
PineNuts0
  • 4,740
  • 21
  • 67
  • 112
2
votes
2 answers

Can't get "update from subquery" statement to work in Oracle SQL

I've looked all over, but can't figure out how to update a column in a table based on subquery data when matching on a customer ID. Here's some syntax to give an idea of what I'm trying to do: UPDATE TableName SET TableName.Revenue =…
MattB
  • 714
  • 1
  • 8
  • 18
2
votes
2 answers

Can I set multiple columns to NULL in MySQL in bulk?

I have a very large database and for testing, I want to set a certain amount of data to NULL. As an example, I have 57 columns across 3 tables, all of which need to be nullified. I can't delete the rows, I just need to know that if the row exists…
CostUnknown
  • 31
  • 1
  • 2
2
votes
2 answers

How to update sqlite row with concatenate existing values in row with a new value

I would like to add a value (concatenate) at the end of existing values in a column of sqlite table. ie: the column contains : banana, orange, pear, pinapple I want to add lemon at the end of the column to have : banana, orange, pear, pinapple,…
moi
  • 45
  • 1
  • 4