Newest 'sql-update' Questions

Q&A for professional and enthusiast programmers

Update SQL column, based on complex conditions from other columns

I need help with figuring out how to update values in a SQL Server column, based on two additional criteria and enclose the while in a "foreach" (I know there is no foreach in T-SQL) loop. I managed ...

This query runs fine, but as an update statement in Oracle it fails [duplicate]

SELECT arinvt.buyer_code_id FROM arinvt LEFT JOIN arinvt_vendors ON arinvt.ID = arinvt_vendors.ARINVT_ID where arinvt_vendors.vendor_id like 61690 and arinvt_vendors.is_default ='Y' and arinvt....

Save DataGrid data into DB

I have one update button in DataGrid, and I want to update data in database With the help of DataGrid update button, the name of update button is SettingsUpdateDataGridUpdateButton. I have table ...

SQL query update column value twice in single query (MySQL)

I have a text column named data which has value in format "`set1:val1,val2|set2:val3`" so I have 2 sets field and n number of value fields in each set. I know this isn't normalized or proper ...

Update table rows that are equal to view row

I have view that contains representation of duplicate guids GUID ---- 1234 5524 1111 Then I have table like that: ID|SomeColumn|GUID --+----------+---- 1 |value1 |1111 2 |value1 |1112 3 |...

Combining X number of Update Statements in one Update Statement

I have three update statements in a script that brings in data from another table and populates TOCTASK accoring to matching C, I values. TOCTASK is large and each statement takes a long time to run, ...

Android GreenDao Update a single field with condition

I am new with greenDao (version 3). I have a table with a status field. I have a list of IDs. I want to update all of status to 'active' with IDs. I failed to get the any such method for this update. ...

MySQL - update row if some column value equals else insert row (NO DUPLICATE KEY)

I have a table that stores meta values, however, in insert/update I want to perform - there is no unique key (not even a combination of columns). 1 column stores ID of a post, 1 a varchar key of a ...

NOT IN clause is not working within CASE WHEN SQL Server statement

I've used below query within a stored procedure: IF (@rowindex = 0 AND @sectionID IN (95, 165, 231, 232) AND @Priority = 0) BEGIN UPDATE SpecialTagContent SET IsVisible ...

SQL Multiple Updates vs single Update performance

Assume I have 10,000 rows that need to be updated. What would be faster UPDATE DB.Servers SET Live = 1 where name = 'server1'; UPDATE DB.Servers SET Live = 1 where name = 'server2'; ... UPDATE DB....

Part of the update is not working in Procedure

I have written two update statement in my procedure. For some strange reason first update statement only update some of the record (basically I update more than 100,000 rows). So second update ...

How can I alter this to run in postgresql?

What needs changing for this to run in postgreSQL? I was given the piece of sql UPDATE ACC SET ACC.ACC_EC = SITESmin.ACC_EC, ACC.ACC_NC = SITESmin.ACC_NC FROM ACC INNER JOIN LATERAL (...

how can i update fields value in my table using the results of my newly created query?

this is my first query(RQ query) SELECT DISTINCTROW Restock.[Stock ID], Sum(Restock.[Quantity of restock]) AS [Sum Of Quantity of restock] FROM Restock GROUP BY Restock.[Stock ID]; i used the result ...

UPDATE FROM WHERE Subquery SQL Server

How can I use a subquery from an UPDATE statement? Here is my query: UPDATE car_availability SET availability_status = 'GOOD' FROM car_trip AS TRIP WHERE car_availability.car_no = TRIP.car_no ...

MySQL insert on duplicate update multiple conditions

I have the following table "texts" +---------+-------------+-------------+-----------+--------------------+ | txt_id | txt_lang_id | txt_section | txt_code | txt_value | +---------+-------...

sql server update statement not working

I tired to execute the below simple update statement in sql server. Once i execute the statement, it shows '2 rows updated', but the data in the table is not yet updated and the IsTransferred column ...

Postgresql RAISE EXCEPTION when operation get 0 or less in Update

I have three tables: CREATE TABLE public.art_movimientos ( cmovimiento bigint NOT NULL DEFAULT nextval('art_movimientos_cmovimiento_seq'::regclass), tipo character varying(3) NOT ...

SQL Syntax error when using INTERSECT in UPDATE query

I have two queries running, one to find matches within a database, and a second query which then updates a column in the database. The queries are exactly the same, except one is a SELECT statement ...

How to generate SQL update statements with IDE?

I have table in dev environment something like this EMP_ID NAME DEPT 1 A AA 2 B BB 3 C CC and I have same table in test environment but ...

ERROR: more than one row returned by subquery

I have the following SQL query (Using Postgre, pgAdmin3) update "Customers" set "PID"=(select PID from person left join "Customers" on "Customers"."Email"=person.Email where "Customers"."Email"!='' ...

Update a column in a function using plpgsql

I am writing a trigger function in PostgreSQL 9.5. When a column named action_flag is updated from FALSE to TRUE, a function is called. If order_num is in some table, then I want the update from ...

got error while update table with use of update trigger

SELECT @idTable = T.id FROM sysobjects P JOIN sysobjects T ON P.parent_obj = T.id WHERE P.id = @@procid -- Get Modified columns SELECT @modifiedColumns = ISNULL(@...

Larvel 5.3 Update record .Only update changed record and leave the unchanged record

I want to update a profile and when I update the record, the old data that I didnot change is also updated. I want to update only those values that are changed. Unchanged values should not be updated....

PHP ODBC : Updating Form

I have a form and successfully connect them to the database. Now I'm trying to update the data. Unfortunately, nothing happened when I click the submit button. I'm sure I miss something. Please help ...

mysql update field with value from another field in same table

I have a table like this: ---------------------------------- | id | date1 | date2 | type | ---------------------------------- | 1 | NULL | NULL | A | | 1 | NULL | NULL | B |...

Append value using update in Sqlitedatabse in android [duplicate]

I have two columns in a row of table namely ID & Name. I want to update (append) some new names to existing Name column value for a particular id using SQLiteDatabase.update(). I am updating ...

OrientDB update query throwing exception for removing list references (rowid's)

UPDATE Student REMOVE couses = #25:183 Student is a class which contains couses field of List type. There is another table Cousre which is having course data. When I try to remove course rowid ...

Using bind_param to update a table gives an error

Hey guys I'm getting a syntax error using the following code, and I've been googling for days trying to figure it out. $sql = "UPDATE account SET username=?, sha_pass_hash=?, email=? WHERE username=?"...

SQL Server : trigger update column of table after other table insert or update a record

I have 2 tables, ShareButton and SharePage. ShareButton table: +----+---------------+---------------+ | ID | Name | TotalShare | +----+---------------+---------------+ | 1 | Facebook ...

Update statement with unmatched condition

I have a update query as follows- udate table1 tbl_out set column1 = (select colValue from table1 t1, table2 t2 where table1.product_id = table2.product_id and t1.id = tbl_out.id) where ...

after performing delete and update queries with in the transaction block. The orient DB throwing the error while accessing updated table?

Orientdb v1.0.1 the following operations are performed from java program with in the transaction db.begin(TXTYPE.OPTIMISTIC); 1.delete from course table with rowid 2.removing course rowid from ...

Concatenate two columns and replace one of them with a result in postgresql

I have a table where in column location there is the folder of the file, e.g. '/home/ubuntu/test' and in the name column, there is the filename e.g. 'test1.png'. I would like to replace the location ...

run Queries and Reporting

what is the best scenario to run query and build a Report, without lock the live database? normally all queries and reports are related to Gatedate() -1 (not the live records). my point of view is: ...

How to update all fields but one certain field statement in MySQL?

Suppose I have a table 'tbl' with 4-field schema: f1,f2,f3,f4. I have bunch of data (in csv form whose list order of fields are same as table schema's [cause I design it] but leave the field-f3 value ...

simple update query dosn't work for column value decrement

I want to run this query : update table_name set Debt = Debt - 5 where Id = some_value but it decrements the 'Debt' column as twice value of given number in query (hear 10) it also works for '+' ...

Cannot update a column in sql?

I cannot update my remarks column using the below query update Customers set customers.Remarks = remarks_stg.remarks from (select remarks from remarks_stg) remarks_stg where customers....

PHP update order by date added not working

function post_data($update_data){ $session_user_id = $_SESSION ['user_id']; $user_data = user_data($session_user_id, 'username', 'email'); $email= $user_data['email']; $update= ...

MySql Update where table_A.col_1 Between table_B.col_1 and table_B.col_2

can you help me with an sql query? I want to get a value from another table but cannot use an inner join because the "join" column is not exactly the same in these two tables. Instead I must check ...

How to select multiple columns in the db?

I will Update more than one table in the PostgreSQL db. They all have similar names. For example: usa-al_nt_2016_q3_a_2-8-1b1 usa-ak_nt_2016_q3_a_2-8-1b1 usa-al_nt_2016_q3_a_2-8-1b1 How can I ...

Php code doesnt update in sql

Can you help me find down what wrong is this code. It say successed but in sql doesnt change. it is something wrong with $est = intval($_GET['est']); Plz help. ?php session_start(); require_once("...

Updating Columns in SQL Server using triggers

I have a table that is updated by an external application. I have the following Columns: OldReading OldReadDate MeterReading ReadDate ConfirmReading MeterReading, ReadDate and ConfirmReading are ...

SQL Update Query Issue #1054

I don't code often and am stuck on something that should be simple. I'm trying the following: UPDATE `wp_usermeta` SET `class-count` = class-count+1 WHERE user_id = 7 but am getting an error ...

Excel-VBA SQL UPDATE Error “No value given for one or more required parameters”

I'm trying to update NUM_ID to 1 where NUM_ID is 4. My table looks like this range A1:A6 NUM_ID 1 1 4 2 2 Excel returns error "No value given for one or more required parameters" on code below. ...

Issue with the update cluase

I am facing one issue in the update clause. I am trying to do the below: update AM1 from DB.AM_7541 AM1, (sel distinct TRIM(SB.LCDBDN) NEID, trim( leading '0' from sb.lcdmno) LCDMNO, AM.Netw_equip ...

SAS update multiple records for a by group

I have a master A and transaction set B. I am trying to udpate records in A with the records in B by variable C. DATA TEST; UPDATE A B; BY C; RUN; The issue is, I have got some duplicate ...

Accessing a previously updated column in the same query behaves differently with JOINs / multi-table UPDATEs

Say I have the two tables players and stats with the following content: mysql> select * from players; +----+-------+ | id | alive | +----+-------+ | 1 | 0 | | 2 | 1 | +----+-------+ ...

SQL server update statement getting Null

UPDATE Newchat Set [Answered] = (Select b.[Answered] From Table1 b where Newchat.CHAT_ID = b.[Chat ID] and Newchat.Chat_Date >= '2017-Feb-22' and Newchat.Chat_Date <= '2017-...

updating last 2 char in varshar

I want to make this update update c_order set documentno = 'OV1036477' where documentno = 'OV1036503'; update c_order set documentno = 'OV1036476' where documentno = 'OV1036502'; ....etc for all ...

SQL tables with different detail level - one containing the sum of the other

I am trying to build a simple model with tables containing forecast data. The first I will call [Year Forecast] and the second [Month Forecast]. Like so: | Year | Forecast | ------------------- | ...

MYSQL Update column in Case

I want to set object_type Elite, Premium or Regular by price value, how i can update object_type column in my DB? My SQL request looks like: select price_per_m2, ( CASE WHEN ...
Translating... 0%