Newest 'sql-update' Questions

Q&A for professional and enthusiast programmers

Iterative UPDATE loop in SQL Server

I would really like to find some kind of automation on this issue I am facing; A client has had a database attached to their front end site for a few years now, and until this date has been inputting ...

Updating multiple rows SQL

i tried to search and search but i couldn't find a matching answer. I need to update 300 rows in the database and the query seems to become longer and longer. I know i can make a temp table somehow, ...

mysql select, insert and delete works from java program, but update not working

I have a table with primary key id, select, insert and delete queries all work from java program, but update query not working, so as to 'insert on duplicate update'( only works when record doesn't ...

Filter rows by field in Mysql

I want if staff go to application page to view the list of application from student. it will only view the status of apply_status = 'PENDING' . status that already approved before will not view in the ...

Updating data inside Listview rows to database table not working

Basically I have bind Listview from existing database with editable textboxes. & I have two different buttons for Update that data. I have made below method to update listview data & calling ...

DB2 update in Loop does not execute

I have the following code: BEGIN DECLARE cmd VARCHAR(1024); DECLARE attr CHAR(10); DECLARE attr2 CHAR(10); DECLARE at_end INTEGER DEFAULT 0; DECLARE not_found CONDITION FOR SQLSTATE '02000'; ...

How can I update a column with PL\SQL by using a calculated value

I created a dummy database for learning purposes, and I purposefully created some duplicated records in one of the tables. In every case I want to flag one of the duplicated records as Latest='Y', and ...

MySQL : update with Where clause in subquery

I used to know how to do this but a lack of practice made me lose it. I am trying to update usernames from a table by comparing matching email in another. basically the first table has username empty,...

most efficient way to update all negative values in a table to NULL in MySQL [on hold]

I can update all the negative values in a table to NULL for one column: UPDATE table_1 SET var1 = NULL WHERE var1 < 0 ; This is great but I have 200 columns which I want to apply this UPDATE ...

MySQL Query Causing Deadlocks

I am dealing with a query that is causing some deadlocks, I believe because it's trying to SELECT from the same table it's updating. Regardless, this is a terribly clumsy way of doing this and I'd ...

What's the columns updating order when several columns are updated?

I have simple table: Col001 Col002 ... ColNNN ... Col001_DateTimeModified Col002_DateTimeModified ... ColNNN_DateTimeModified The ColXXX is holding value and the ColNNN_DateTimeModified is holding ...

How to copy changed format of date to another column in same table MySQL

I've got one table with two columns, one timestamp with timestamp and second with date in '%Y-%m-%d' format. I need to get timestamp from timestamp column, convert it to '%Y-%m-%d' and put it into ...

Update command not working but there is no Error

I have a table named MesaiBilgileri and columns Id, AdiSoyadi, Mesai, MesaiTarih... I'd pick the info from table named PersonelBilgileri with this code: private void ...

Update table based on current record

In my PostgreSQL database I'm converting from integer keys to UUID for various reasons. So right now I have table Person with an ident serial primary key, and table TeamPerson with a person_id ...

Bad Update Data in PHP PDO

Well, I'm working around with PHP with PDO extension as the database driver. I'm working on a 'changing password' scenario where things is pretty messed up for me :( We (some Stackoverflow helpers, ...

Toggle bit for a series of rows based on single row in SQLite

I have a table containing rows which are either 'headers' or 'normal', non-header entries. This is tracked by an INTEGER affinity column IsHeader. Likewise, I have a column tracking if the row is '...

Update a table with results from multiple tables

Currently using Microsoft SQL Server 2012 (Management Studio), looking to update a column in a table with a query which uses data from another table. This is the query I am running: SELECT ...

SQL Server / Oracle: How to increase index column dependent on another column?

Given the following table: Column1 Column2 idx ------------------- 1 1 0 2 1 0 3 2 0 4 3 0 5 3 0 1 3 0 How could I increase ...

Update Database Row on HTML Button Click

I currently have a table that has data imported from a SQL Server database. The table also has an edit button for each row where I can choose to edit a certain row if I want to. On Save, it should ...

Update All other Records Based on a single record

I have a table with a million records. I need to update some columns which are null based on the existing 'not null' records of a particular id based columns. I've tried with one query, it seems to be ...

The second main if(empty($ureciver )) statement does not execute at all..what am i missing

I'm working on a two table mysql database with tables p and g. Here I'm trying to check if the value of a variable $ureciever returned from a select query on table 'p' is empty or not and based on ...

How to update column value when system datetime reach datetime saved in other column? in sqlserver

I have one table with 2 columns. One is called "houranddate" and is datetime type and the other is called "status" and is int type. I want the value in "status" column to be updated to "1" when the ...

VB .NET Column name or number of supplied values does not match table definition… but im updating not inserting?

Inherited a vb .net web forms page. SQL Server database. THE CODE ISNT SHOWING A FIELD ADD - First, before running the below code , I add a 'myfield' to a table named 'mytable' in SQL server ...

How Update a table from 2 variables of another table?

I have 2 table, in table A I have id_A and region_A, in table 2 I have id_B and region_B I want to set region_A = region_B when id_A is equal id_B I read this question and tried : UPDATE A SET ...

Database not updating in Java

The code doesn't want to update and says that there is an empty string when getting the currency name from the combobox(getCurType). Although it posts in the println statement post otherwise and shows ...

MS SQL server update takes way too long

I have a "update" statement including a few inner joins. I run it on 400K rows and it takes about 11 minutes to execute which is way too long. I run the same statement on Access db and it takes 2 ...

Incorrect syntax error for Update-Inner Join statement

I'm using Microsoft SQL Server and when writing this code I am getting an incorrect syntax error for the "Inner" and also "=" within the SET line. I've looked into this and think everything is set up ...

Knex.js - How To Update a Field With An Expression

How do we get Knex to create the following SQL statement: UPDATE item SET qtyonhand = qtyonhand + 1 WHERE rowid = 8 We're currently using the following code: knex('item') .transacting(trx) ....

Can we update values in a table by using if condition?

I have 4 tables. The identifiers are different. Hence, in Table 4 we have data to connect both the tables. But there is no relation between Table1 to any of these other 3 Tables. I have to verify ...

Sphinx best way WHERE and UPDATE on MySql table

I kind used in MySQL query: UPDATE Tovar Tovar INNER JOIN ( SELECT * FROM (..... SELECT * FROM ....) as `tmp` ON CONCAT(' ',Tovar.drugApt,' ') LIKE ...

Editing an HTML Table Row and Update to Database

I have an edit button that can be clicked in each row of the my HTML table that I currently have. Currently, when I click "Edit", I can edit the cells in the corresponding rows and columns, but when ...

Is there a non-commercial alternative to Z.EntityFramework.Extensions?

Entity Framework can be very slow on mass insert/update/delete operations. Even the often suggested tweaks to turn off AutoDetectChanges and/or ValidateOnSaveEnabled does not always help. I have come ...

SQL Server Trigger to update the table column based on Insert or Update of the same Table

I'm having two standalone tables 'Person' and 'Bank' in one database. Moreover I'm having one Reference table 'Customers' in another database Table: Person - Database #1 PersonId (PK) Name ...

SQL Update multiple rows and columns with subselect query

I have the problem of needing to update multiple columns (2) in multiple rows (7) from a subselect query. Here is what I have so far: UPDATE commandtbl2 t1 SET (attr, attr2) = ( SELECT attr, attr2 ...

unable to update the record in mysqli [duplicate]

I am just trying to access following code but unfortunately, I couldn't run this script successfully. always got an error not updated. in my db i have only 3 field id, lname, fname here is following ...

Update SQL query multiple fields to update

Trying to update my tables by an update query, please see below the query, not sure if its the and that is giving me the issue? update tb1 set class='X' and SUB_CLASSIFICATION='XX' where id=12345 and ...

Why does PostgreSQL complain about type when I use CASE to SET a field to NULL?

I have the following query: UPDATE managed_avs SET own_license_expires_at = CASE id WHEN 50 THEN NULL END WHERE id in (50) I get the following error: ERROR: column "own_license_expires_at" ...

Admin Cannot Update Student Profile

currently im doing my final year project which is advising system for student. My problem is that admin cannot update a certain data of student. At my first try, it says that, admin done update ...

Switches in PHP and PDO

I'm thinking of a switch in PDO, which can change the query (such as UPDATE, INSERT). Here is my example code: $insertsql = ":SYNTAX INTO `grades` (StudentID, gradeID) VALUES (:SID, :GID)"; and in :...

Replace with undefined character in Postgres

I need to do an UPDATE script using the Replace() function of Postgres but I don't know the exact string that I have to replace and I'd like to know if there is some way that I can do this similary ...

Update query not working in codeigniter?

model.php public function verifyLogin($username, $entered_password, $captcha_input) { $this->db->trans_start(); $sql = "SELECT name, selector, ...

TSQL - Converting 1 line address into 3

So ive found ive got a list of addresses (street, suburb, postcode) and added them into a table tmp_addresses. My idea was to split up the current addresses that are all in one line using the ...

MySQL: PK give error when updated even though FK CONSTRAINT is set to ON UPDATE CASCADE

I'm using MySQL and I am trying to change the value of one of my PK attributes. The FK connected to it is set up with ON UPDATE CASCADE. When I try to change the PK value, I get the following error: #...

Is it possible for a SQL update query to run partially?

I'm maintaining a website I developed a couple of months ago now and there is a query that sometimes runs partially (or something). It updates an account level and deducts its cost from the account ...

Why does this UPDATE query not update my table? [duplicate]

I am trying to code a user system. I code almost everything my system except activation. I can select and insert data to my table but now Iam trying to active account and got stuck. <?PHP include "...

Mysql php Update doesnt work in while loop

I am new in programming and I came across issue with Mysql Update code. I have 4 different row values in '100m' Column and I am trying to use While loop to calculate $points1 for each different value ...

Update Most Recent Record, with Date and Time in two columns, Time Dependent on Date

I need to select the most recent record by date and time. The date and time are in two separate columns. I can select the max on time in the where clause. Is the best way to get the max of time by ...

TSQL syntax for updating with inner join

I'm trying to convert this mysql query to run on SQL but having some issues with the syntax on join. Basically what I want to do is set the DWH_HISTO to 1 on duplicate rows based on the DWH_DATE. So ...

Teradata SQL Update Table “Query Error 3802 Database 'oo' does not exist”

I need help with the following query code. Currently it is giving me the 3802 query error "Database does not exist". Well I did my "from" selection query as 'oo', so that definitely exists. This ...

How to update selected row in Gridview?

I have a TextBox with id=txtPlace and a gridview. If a user selects a row an put some Information in the TextBox and click on save. The Information should replace older records in the database(SQL) ...
Translating... 0%