FAQ Database Discussion Community


mysql_query string not updating

php,mysql,sql-update
I am having some trouble with my code: <?php include("./header.php"); //Validate login if(!isset($_SESSION['user_id']) && !isset($_SESSION['invite_id'])) { echo "<meta http-equiv=\"refresh\" content=\"0; url=/\">"; } else { $user_login = $_SESSION['user_login']; //Get whether user clicked submit $submitSuitDesignCredentials = $_POST['submitSuitDesignCredentials']; if (isset($submitSuitDesignCredentials)) { //Store user input in variables and remove unwanted characters $neckcircumference = preg_replace('#[^0-9.,]#i','',...

Basic CakePHP: Unable to get the id (Edit Method)

cakephp,sql-update
This my database: http://gyazo.com/c6a86127d6f91aae947cf45ee535cecd Example: http://gyazo.com/c23fec3fabb7e4504c42453980fbc372 When I press the edit button , they able to retrieve the data however the page show me empty field instead of the field that have old data. Secondly, unable to undate because they keep send empty id_field back to controller. p.s. add,edit,delete method...

How to handle no rows returned in an Oracle update using a common sub-select

oracle,null,sql-update,subquery
Consider the update: UPDATE table1 SET c1 = NVL(( SELECT d1 FROM table2 WHERE table1.id = table2.id ), 0), c2 = NVL(( SELECT d2 FROM table2 WHERE table1.id = table2.id ), 0) The NVL function handles the case where the sub-select returns no rows. Is there a good way to...

Exchange values stored in 2 columns of a table

mysql,sql-update
I have a table as below: items: name VARCHAR(50), //STORES Item's Name brand VARCHAR(50), //STORES Item's Brand sales_rate DOUBLE(8,2), PK(name, brand) This table's primary key is foreign key to other tables in the database. Now my problem is that user by mistake inserted the item's name in the brand column...

Weird SQLite behaviour - non-functional UPDATE SQLite method

java,sqlite,intellij-idea,sql-update,insert-update
I am creating a Java desktop application that uses and SQLite database with over 50 data variables. I have a DatabaseHelper class that has the following variables: //-- The SQLite Database Table name --// private static final String STAN_RECORDS_TABLE = "STAN_SQLite_Records_Table"; // Primary Table - Table 1. //-- The STAN...

Java SQL update one table dynamically from another without id

java,sql,sql-server-2008,sql-update
I have two tables like this : Table 1: Description -- Price Apple 10 Wine 20 Coffe 5 Table 2: Description -- Price -- Number Pineapple 25 1 Coke 5 1 Orange Juice 8 2 Milk 10 3 I want table 1 to look like this (): Description -- Price...

MySQL change ROW1 if ROW2 contains “string”

php,mysql,sql,sql-update
I have a list of items in a database. I have the columns item_name and is_tradable. I want to be able to go through the names in item_name and check if they contain a certain string, e.g. "Gold". If they contain that string, change is_tradable from 'yes' to 'no'. e.g.:...

Postgres 9.2 find, compare and replace two values in column

sql,sql-update,postgresql-9.2
Hi i am trying to run a query to find two values in the same column, compare them and set the highest value to both and I am get a bit confused. I can not work out how to do it prettily so I have gone for an ugly approach...

summing from two tables then preforming an operation with the 2 sums

sql-server,insert,sum,sql-update
I am using sql server and I have a table called accnt with the fields ven1 and amnt1 and a table called acc1167 with fields ven, job#, and amnt. for this example these tables look like this accnt acc1167 ven1 amnt1 ven job# amnt 1167 100 1167 1 200 1152...

Sql UPATE with multiple conditions in WHERE clause

sql-update
UPDATE Table1 SET [Marks] = ( SELECT CASE STATEMENTS FROM Table2 T2 WHERE Table1.ID = T2.ID) ) The above UPDATE statements works fine, but if the ID doesn't match then it insert NULL value for 'Marks'. But i wanted to keep the original value for Marks in Table1 if the...

Update Query With Inline

sql-server-2008,sql-update
Is it possible to do an update query like this? It may not be, just a thought I had as to possibly a solution to my predicament of terrible data-structure. What I am trying to accomplish is: To update the table prodinformation with a count where the entrytype exists in...

Update a table using info from a second table and a condition from a third table in Postgresql

database,postgresql,join,sql-update
My current code is as follows UPDATE product_template SET listprice = product_uom.factor * product_template.list_price FROM product_uom INNER JOIN product_template ON product_uom.id = product_template.uom_id INNER JOIN product_product ON product_product.id = product_template.id WHERE product_product.manufacturer = 2646 As I understand line 1 specifies which table I want to update. then I specify that...

SQL Update row column with random lookup value

sql-server,sql-update
I am trying to update a lead table to assign a random person from a lookup table. Here is the generic schema: TableA (header), ID int, name varchar (30) TableB (detail), ID int, fkTableA int, (foreign key to TableA.ID) recordOwner varchar(30) null other detail colums.. TableC (owners), ID int, fkTableA...

Atomic increment of counter column using simple update

sql,transactions,sql-update,atomic
I am trying to understand how to safely increment a counter column, that may be incremented simultaneously by many users (It's a Web API for a mobile app). I've read the popular questions in SO for strategies dealing with the issue but I can't seem to figure what's wrong with...

SQL: How to update all rows with a calculation?

sql,sql-server,tsql,sql-update
I'm trying to add in the total price for a pizza order based on the order sub-total and tax. I've been getting an error stating the subquery returned more than 1 value with this command: DECLARE @orderTotal AS INT SET @orderTotal = (SELECT(SUM((orderSubtotal+tax) * (1 - discountAmount))) FROM OrderProcessing GROUP...

update and using sum to calculate column value

sql,sql-server,sql-update
I am using sql-server. I have a table which contains the value of a list of companies. I wish to workout the % of each company as part of this list. See example below name value wgt% abc 10 plm 15 xyz 25 So above is what I have, below...

How can I add FOR UPDATE to a cakephp3 query?

select,transactions,sql-update,cakephp-3.0,isolation-level
Is there a way to add FOR UPDATE to a find (SELECT) query in cakephp3? I found this hack: http://bakery.cakephp.org/2012/04/14/SELECT-FOR-UPDATE-hack-kind-of-ugly-but-it-works-PostgreSQL-and-MySql.html but it does not work since the limit value must contain only of a number. Another discussion on a similar topic can be found under https://github.com/cakephp/cakephp/issues/3136#event-213462937....

MSSQL Deadlock when update withc (updlock)

sql-server,tsql,sql-update,database-deadlocks
I got deadlock while updating. The transaction level is set to Read Committed. How to avoid deadlock in such situation? In other cases WITH (NOLOCK) and WITH (UPDLOCK) helped. I got the following T-SQL query: IF EXISTS (SELECT 1 FROM DEBTORS_CUSTOMERS WITH (NOLOCK) WHERE DebtorId = @DebtorId AND ClientFCCustomerNumber =...

Update inserted record on a trigger

sql-server,triggers,insert,sql-update
I'm having troubles while trying to update a record when it is being inserted into a database via external application. I need the record being inserted from the users in the application takes a value MinimumStock from a table AERO_LOCATIONSTOCKMIN on which are the parent location and the asset type...

Update Microsoft Access Table Field from Excel App Via VBA/SQL

sql,excel-vba,ms-access,access-vba,sql-update
I am successfully able to connect to database, but the problem is when it updates table field. It updates the entire field in table instead of searching for ID number and only updating that specific Time_out Field. Here is the code below, I must be missing something, hopefully something simple...

MySql Incrementing a cell value with a Unique Key constraint

mysql,sql-update
I have a table with items that can be sorted which looks somewhat like this: CREATE TABLE `mytable` ( `uid` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(1024) NOT NULL, `position` int(11) NOT NULL PRIMARY KEY (`uid`), UNIQUE KEY `Position_UNIQUE` (`position`) ) As you can see, position is required to be unique....

Wildcard column name in UPDATE query

php,mysqli,sql-update
Assuming I have a SQL table called techsched setup as below but the 800,900 etc. etc. went on till 2300, each representing a one hour block of time. a six character alphanumeric character (TPI232) represents a ticket number assigned to a tech and the ticket number is duplicated across each...

error message with update query in mysq, php

php,mysql,syntax,sql-update
I am using this syntax to update message: $uname=$_POST['username']; $ans=mysql_query("UPDATE userdata SET tag1 = '$tag1', tag2 = '$tag2', tag3 = '$tag3', pass1='$t1', pass2='$t2', pass3='$t3', WHERE username =$uname") or die("Invalid query: " . mysql_error()); $uname is userxyz here and error message is: Invalid query: You have an error in your SQL...

replacing vales in one table with values from another table using multiple criteria

sql-server,database,sql-update,inner-join
I have two tables, one called accajd, which a screenshot of is shown below, which has the old and new values in it. and one called jobcost with about 15 fields, 3 of which need to be updated with the data from the accadj table (accno, jno, and saccno). What...

Postgres UPDATE FROM set value according to result of other query

sql,postgresql,sql-update
I'm stuck with an UPDATE. My tables originally were: Clients ------------------ ID Emails Notification_type Contracts ------------------ ID Client_id (FK) Contracts_document_types ------------------ Contract_id (FK) Document_type_id (FK) And I could notify basing on Clients table. Then I had to change the notification method. My database changed to: Contracts_document_types ------------------ Contract_id (FK) Document_type_id...

postgresql update multiple tables in single query

java,sql,postgresql,sql-update
I have 2 tables as below: serial_table id CHARACTER VARYING(20), serial_key CHARACTER VARYING(20), PRIMARY KEY(id, serial_key) serial_rate: id CHARACTER VARYING(20), serial_key CHARACTER VARYING(20), rate NUMERIC, PRIMARY KEY(id, serial_key), FOREIGN KEY (id, serial_key) REFERENCES serial_table(id, serial_key) now I want to update serial_rate.rate and serial_table.serial_key from a single SQL Query like :...

MySQL update DATETIME to NOW() using PHP

php,mysql,datetime,sql-update
This all worked before I added the section to update "last_update". if((time() - $last_update) > 7200){ $sql = $dbh->prepare("UPDATE item_list SET quantity=:quantity, price=:price, last_update=:now WHERE item_name=:itemname"); $sql->bindParam(':quantity', $json->volume); $sql->bindParam(':price', $json->lowest_price); $sql->bindParam(':itemname', $row['Item_Name']); $sql->bindParam(':now', "NOW()"); //This doesn't work $sql->execute(); } When this is called I want to make last_update the date...

How to update table1 field by using other table and function

oracle,plsql,sql-update
I have two table and one function, Table1 contains shop_code,batch_id,registry_id shop_code| batch_id|registry_id 123 | 100 |12 124 | 100 |13 125 | 100 |12 Table2 contains shop_code,shop_name shop_code| shop_name 123 | need to populate 124 | need to populate 125 | need to populate Function1 take parameter registry_id from table1...

Can't update SQL table [closed]

c#,sql-server,parameters,sql-update
I need to change values in table Iepirkumi to values that are in textboxes. Debbugger shows no problems, but the code doesn't work. string connectionString = (@"Data Source=(LocalDB)\v11.0;AttachDbFilename=""C:\Users\Davis\Documents\Visual Studio 2013\Projects\WindowsFormsApplication1\WindowsFormsApplication1\dati.mdf"";Integrated Security=True"); using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); using (SqlCommand cmd = new SqlCommand("UPDATE Iepirkumi SET"+ " [Pieg_Nos]='@Pieg_Nos',"+ "...

Basic CakePHP: Edit Post Method become Add Post Method

cakephp,methods,sql-update,edit
Currently following the blog tutorial however my database and their variable are different. I was looking through the "Edit Post" method and follow the step they given however they turn into "Add Post" method. What is the reason that cause it ? (I have set the hidden field at view...

sqlUpdate returns error “[RODBC] Failed exec in Update” when updating table read from DB

database,r,sql-update,rodbc
I'm creating a table and writing it to a database with RODBC. No problems. First I tried updating the table in R and writing the updates back line by line using sqlUpdate in the same R script and the same R session as initialising it. No problems. But when I...

How to update SQL table from other table when they are on different servers

sql,sql-server,database,merge,sql-update
I've already run the following command to include another server instance. EXEC sp_addlinkedserver @server='Server' Now I'm trying to synchronize these databases using this: UPDATE [Server].[ServerDB].[dbo].[tableName] SET [Server].[ServerDB].[dbo].[tableName].[columnName] = [LocalDB].[dbo].[tableName].[columnName] FROM [Server].[ServerDB].[dbo].[tableName], [LocalDB].[dbo].[tableName] WHERE [Server].[ServerDB].[dbo].[tableName].id = [LocalDB].[dbo].[tableName].id This gave me the following error: The objects "LocalDB.dbo.tableName" and...

SQL UPDATE field using value from another row with criteria

sql,sql-update
I have a table ItemPriceId Version PricingSchemeID UnitPrice LastModUser LastModDttm TimeStamp ProdId This table contains multiple pricing schemes for approximately 1300 items. What I am trying to do is alter one of these schemes to be a multiple of another scheme. So if the PricingSchemeID = 102 I want to...

SQL update method returns JSONException

php,android,mysql,json,sql-update
I have a simple MySQL table on my server with 4 fields. pid, aid, uname and active. I am sending the uname variable via my android app to my PHP code and I want to change the boolean active column from 1 to 0 where the uname field is equal...

mySQL prepend text to column if not null

mysql,sql,sql-update,concat
I just did a mass import of 200,000 items into the database, but forgot to add the directories under the image column. Is there a way to mass update the column and prepend the images directory? This is what I've been trying, but it doesn't work: UPDATE wp_store_locator SET sl_image...

Replace null with same value per date - oracle sql

sql,oracle,sql-update
I am trying to make a query that updates VAL by setting the same value to all the HOUR hours within the same DATA day. It has to somehow check for a value in the same date and replace the nulls with it, but I can't seem to get my...

Alter sql table with new foreign key values

mysql,sql,sql-update
I have 'locations' database and two tables. My first table was 'uszips' which looks like: --id--zipCode--stateCode--latitude--longitude-- 1 35004 AL 33.584132 -86.515570 2 35005 AL 33.588437 -86.959727 Now, I have a second table called 'usstates' and I have 2-letter state codes already there: --id--stateCode-- 1 AK 2 AL I was not...

update table based on another tables value in sqLite

sqlite,join,sqlite3,sql-update
We have two tables table1 table2 In table1 Itemnumber SalesCode 123 213UB 142 132NB 1458 256GD In table2 Itemnumber ProductGroupCode 123 142 1458 After Update table2 We need Like this Itemnumber ProductGroupCode 123 213UB 142 132NB 1458 256GD We tried like this tx.executeSql('UPDATE table2 JOIN table1 ON (table2.ItemNumber=table1.ItemNumber) SET table2.CustomerPriceGroup...

Update error if data does not exist

c#,sql,sql-update
I managed to create my own "save, update, delete" program with SQL after watching a video. I have an issue, if I click "update" without having the "IndexNumber" in the database, nothing will happen. Can anybody advise me on how to improve my "update" button? Perhaps if the data does...

Getting “Subquery returned more than 1 value” error running update query

sql-server,sql-server-2008,sql-update,insert-update
Please be gentle, I am trying to update the query in sql server but facing an error. Here is my two tables that are in same database and a query furnished below and my requirement is to update the column groupCode in table2 based on table 1 but I am...

INNER JOIN SELECT in MySQL

mysql,sql-update,inner-join
I have an SQL statement that works in SQL Server but fails in MySQL... shouldn't this work in MySQL? UPDATE T2 SET TotalAmount = T1.SumAmount FROM ccs_multiples as T2 INNER JOIN (SELECT SUM(Amount) as SumAmount, SerialNumber FROM ccs_multiples_items GROUP BY SerialNumber) as T1 ON T2.SerialNumber = T1.SerialNumber Error: #1064 -...

sql update table - statement not working

sql,sql-update,access-vba
I have the below statement in my VBA: DoCmd.RunSQL "UPDATE customer SET Status = 'Premier' WHERE customer_id = 41308408 AND location IN ('London','New York') AND Status = ''" which is meant to update a table called "customer". I can see in my table there are about 20 entries where the...

if else not working in update query

php,mysql,sql-update
I have a problem in if else condition. Sorry i am a beginner so please help me. My code is below. $sql1=mysql_query("select * from dbms_master_data where id='".$_GET['eid']."'"); $rst1=mysql_fetch_array($sql1); $new_user='Contact; '.$rst1['user_type']; $sqls=mysql_query("update dbms_master_data set user_type='".$new_user."', cid='".$_GET['vid']."' where id='".$_GET['eid']."' and cid IS NULL"); if($sqls) { ?> <script> alert("New contact added!"); window.location='access1.php?vid=1'; </script>...

SQL Update Table confusion?

mysql,sql,sql-update
I have two tables, communication(that has a column timestamp,FromIDNumber and FromX ) and commLocation(that has a column timestamp,FromIDNumber and x). I want to set communication.FromX = commLocation.x when the two tables have the same timestamp and FromIDNumber. I tried doing this: UPDATE communication SET FromX=(SELECT commLocation.x FROM commLocation JOIN communication...

using CASE to select column for SET in UPDATE statement IN SQL SERVER

sql,sql-server,sql-update,case
I want to execute the following statement. Is it possible to select which column to update using the CASE ? UPDATE TABVAR CASE WHEN M BETWEEN 0 AND 6 THEN SET M0_TO_6 = M WHEN M BETWEEN 7 AND 18 THEN SET M7_TO_18 = M WHEN M BETWEEN 19 AND...

Postgresql: execute update on a temporary table in plpgsql is not working

postgresql,sql-update,plpgsql,execute,temp-tables
I'm trying to update a field in a temporary table I've created. The code for the temporary table looks like this: CREATE OR REPLACE FUNCTION insertTable () RETURNS VOID AS $$ BEGIN execute 'create temporary table myTable (id INTEGER, value TEXT) on commit preserve rows'; execute 'insert into myTable values(1,...

MySQL “UPDATE” syntax is entering 0 in column

php,mysql,pdo,sql-update,ckeditor
I am trying to enter into a table in with PDO if using an if condition. My code for the function is below: function add_user_info($conn, $user, $info, $fName, $sName, $past, $pos){ // Prepare and execute statements $info1 = addslashes($info); $sql = $conn->prepare("SELECT * FROM `User_Info` WHERE `User` = '$user'"); $sql->execute();...

update query using join

sql,join,sql-update,informix
I need help in updating a database using a join query.It is not a straight forward query and kind of confusing. I created a select query to select routelist(d.name) which is equal to 'TP-424-RL'. select n.dnorpattern as RoutePattern, rp.name as Partition, d.name as RouteList, rl.selectionOrder, rg.name as RouteGroup from numplan...

Update part of a string in SQL

mysql,sql,sql-update
I would like to update a part of string in a particular column of my database. I have cm2 in the particular column of my database and would like to update it to cm2. My sql query to find the cm2 is: SELECT * FROM `question_table` WHERE `option` LIKE '%cm2%'...

TSQL update value with subquery

sql-server,tsql,sql-update,compare
I have 2 tables and want to compare them and modify tableA (set NameMod = 1) if it has different rows. To compare tables I use: select Id, Name from tableB except select Id, Name from tableA And then I want to modify tableA: update tableA Set NameMod = 1...

MS SQL IF with a select value

sql-server,if-statement,sql-update
How do I state - If a field in my table is NULL only then do the update. For example: IF customer_day_phone (from my #invoice table) where id_key = @id_key -matches my parameter - is null. Then run my update. But i'll have multiple rows coming back and I only...

Update only day portion of SQL Date

mysql,sql,sql-update
I have a field with random Date types, for example: 2005-01-08 2001-11-15 1988-05-06 I need to change these all to have the same day portion of the date, preserving the year and month. Like: 2005-01-01 2001-11-01 1988-05-01 How can this be done with plain old SQL?...

SQL Update with a Group by Statement not working

sql-server,join,group-by,sum,sql-update
I've got two temp tables. In table @due_cte I have a series of Customer_Ids, followed by payment amounts collected throughout various points in the code. The @work table has a lot of various columns including hist_amt_due. What I want to do is update @work with the amt_due from @due_cte but...

How to update database using php variables ?

php,mysql,sql-update
$Createdby=$_SESSION['adminlog']; $total =$_POST['total']; $due =$_POST['due']; $date =$_POST['issedate']; $invoiceno =$_POST['invno']; $CmpnyName =$_POST['CmpnyName']; $itemdetails =$_POST['item_details']; $itemname =$_POST['itemname']; $amtpaid =$_POST['paid']; $query = "UPDATE billdata SET Total='$total' Due='$due' WHERE InvoiceNo=$invoiceno"; $result = mysql_query($query); this is my code m using to get html values to variable and update particular invoice number with new data...

Copy specific data from one table to another in sql

sql,sql-update,nested,inner-join
I have two tables, one is CurrentReport and other is Challan table, and another is current report table that are showing in table. I copy the value of following column of currentReport table [Title], [ISBN], [Author1], [FinalStatus], [MssType] but now I want to copy stepno of challan table having min...

How do i prevent duplicate records in my database while updating records?

c#,mysql,sql-update,unique
in my mysql table I made look like this one ControlNum|Title |NumOfEpis|Description| 001 |naruto |500 |some text | 002 |conan |700 |some text | now I made a user control in C# where in the user is allowed to update all columns except the primary"ControlNum". so assuming each column has...

Update statement taking too long (7 minutes)

sql,sql-server,sql-update,execution-time,query-execution-plans
This is SQL code im running on SSMS 2008 R2. It's taking over 10 minutes to run (it runs against 90,000 records).. I'm trying to update all unique records in #tmp_hic_final where [Claim Adjustment Type Code] is 0 and [Claim Type Code] is not 10. I'm also doing the update...

Why does this MySQL query spill over to the next line

mysql,sql-update,syntax-error,sql-injection
The input would come in from a web form, and I am attempting an SQL injection via the form. In the password field, I attempt to put a single quote just to see what sort of error is invoked at the back end. I run this same query manually at...

How to update in SQL based on different where clause

sql-server-2008,sql-update
I have a table which has a structure as: ID DBInstance DBName Tag 1 | INS1 | master | NULL 2 | INS1 | tempdb | NULL 4 | INS2 | master | NULL 5 | INS2 | tempdb | NULL I want to update the tag in this table...

Update column information

sql,sql-update
I am trying to update information in the column Mgrstat to a 3 and would like to mass enter the information. As it is I have to use "=" and enter each AppID individually but I would rather enter several at once. The query below shows my attempt using "in",...

MySQL query to update list counts

mysql,sql,sql-update
I have a MySQL problem which I'm struggling to solve. I have two tables. The first is a table of many thousands of garden items each with a groupid, with many items falling into any given group id. The second table is a summary table, simply listing the groupids and...

Load the local table with data from server

android,mysql,sql-update
I have an online database with which my android application contacts. All the details that the app needs, is stored in the online MySQL database. My problem here is, I have a sql query, "SELECT sum(amount) FROM donations WHERE aid = '" + aid2 + "'" which sums the appropriate...

USING IF with UPDATE MYSQL

mysql,if-statement,sql-update
Im trying to do an update with a IF function IF(SELECT 'FUNCION' FROM tickets WHERE (FUNCION = COR) AND (tickets.CLIENTE=clientes.CLIENTE)) THEN UPDATE `clientes` SET `ESTADO` = 'I'; I tried this but it seems I have a syntax error. How can I get this to work? EDIT: I want to update...

an update statement that adds 100 to a total

sql,sql-server,sql-update
How would I write an update statement that adds 100 to the credit total field of invoices for all invoices that were written the first of the year? I'm trying to write a statement like: Update dbo.invoices set credittotal (this is the problem right here where i dont know how...

Adding a column of data

mysql,sql-update,sql-insert
Not been able to find something that matches what I am setting out to teach myself, so here goes: I have added a column (called status) to an existing table (called fruit). All values in this new column are currently null. Other columns in this table are id (primary key...

SQLITE UDPATe OR insert statement doesnt want to execute

java,sqlite,sql-update
public synchronized void saveMatchValue(int photoRecOwner, int[] photoRecAssign, float[] value) { SQLiteDatabase database = databaseHelper.getWritableDatabase(); database.beginTransaction(); String sql = " UPDATE " + TypeContract.CTablePhotoMatch.TABLE_NAME + " SET " + TypeContract.CTablePhotoMatch.VALUE + "=? " + " WHERE " + TypeContract.CTablePhotoMatch.FK_OWNER + "=? AND " + TypeContract.CTablePhotoMatch.FK_ASSIGN + "=? ;" + " INSERT...

Can not run SQL update statement in vb.net,

sql,sql-server,vb.net,sql-update
I am currently working in Visual Studio 2013 Express with a SQL Server backend. I am trying to do a VERY SIMPLE update statement, but for some reason this thing will NOT run. It is beginning to frustate me on how this simple query will not run. This form is...

postgresql UPDATE on condition with group of id's

sql,postgresql,sql-update
------------------------------------------ auto_id | group_id | TOF | TOF_2 | ------------------------------------------ 8001 | 512 | true | | ------------------------------------------ 8002 | 512 | false | | ------------------------------------------ 8003 | 512 | false | | ------------------------------------------ 8004 | 512 | false | | ------------------------------------------ 8005 | 512 | false | | ------------------------------------------...

Insert into Database using OleDbConnection

asp.net,vb.net,insert,sql-update,oledbcommand
I am almost finished with my code but never inserted data into the database before. So far my SQL statement works fine but the final execution of the code I don't know how to do. The new record doesn't show up in my database so I think I am missing...

Oracle sql- replace null with next and p

sql,oracle,sql-update
I am trying to UPDATE a table and replace NULL values but with certain conditions. I created an example below and order it by cases to help illustrate where my conditions apply. 1º - In case there is a NULL value it is supposed to replace with the previous known...

Oracle Deadlock while updating

oracle,sql-update,database-deadlocks
I have a database, which is used by some people and a service for updating personal data at the same time. So there is the possibility, that a person updates a row and forgets the commit. later the update-service always wants to update this row and the service hangs, until...

How to get column name of particular value in sql server 2008

sql-server,select,sql-update
I want to get column name of particular value. I have table CurrentReport having unique id from which i can get particular row now from the values of that row i want to get the name of columns that i need to update .

Merge Query in DB2

sql,merge,sql-update,db2
I need to update few columns in one table with the very convoluted calculation. I'm not good enough in SQL so I tried to use "with" clause in combination with update, but It threw error. Then I found a post online which suggested to use MERGE so I came up...

Updating table with the closest value from a lookup matrix

sql,sql-server,matrix,sql-update,lookup-tables
TABLE 1 First table is the matrix containing reference values, something like this: create table dm_matrix (x float, z float, avgValue float) insert into dm_matrix values (1,1, rand()) insert into dm_matrix values (1,2, rand()) ... insert into dm_matrix values (4,3, rand()) insert into dm_matrix values (4,4, rand()) Creating a matrix...

Postgres - remove element from jsonb array

arrays,postgresql,sql-update,jsonb
I have an array of jsonb elements (jsonb[]), with id and text. To remove an element I could use: UPDATE "Users" SET chats = array_remove(chats, '{"id": 2, "text": "my message"') But I want to delete the message just by the id, cause getting the message will cost me another query....

Postgres error updating column data

sql,postgresql,sql-update
Trying to run a update script on a table, but getting an error: ERROR: column "ok" does not exist LINE 2: SET first_name="ok", last_name="pk", email="ooo", phone="... CREATE TABLE employee ( employee_id SERIAL PRIMARY KEY, first_name varchar(255) NOT NULL, last_name varchar(255) NOT NULL, email varchar(255) NOT NULL, phone varchar(255) ); INSERT...

Sql Query to update a column that contains other column data

sql,sql-server,select,sql-update
I am new to sql queries. I am trying to do the below operation and could not achieve the functionality successfully. Any point would help. I have a table with name column and alias column. There are few names with alias included in them I am trying to filer names...

Insert the same fixed percentage into multiple rows at once

mysql,sql,sql-update,sql-insert
I have data in this manner: ID SUB Marks 1 English 25 2 Maths 22 3 Science 15 4 English 16 How would I sum the "marks" value with a fixed percentage and give total marks of each ID at once? For example, if I have a fixed percentage of...

Compare sql table with txt file line by line with table if variable dosent exsit insert it [closed]

php,mysql,sql,sql-update,requirements.txt
<?php function db_query() { $servername = "localhost"; $username = "root"; $password = ""; $dbname = "single4thenight"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT id, name, alias, type, parent, ordering, published FROM iutca_jomcl_locations";...

Table update based on match/nomatch

sql,oracle,join,sql-update
I have two tables t1 and t2. t1 has this structure: yearmonth account company RCV_amount_t1 t2 has this structure: yearmonth account company billing amount billing amount CM_1 billing amount CM_2 RCV_amount_t2 I want to join t2 to t1 using yearmonth, account, and company. If they match, I want to update...

Update a row(entity) in a table only if a change detected(automatically)

sql-update,entity,detect,cakephp-3.0,changes
Sorry for my bad english :( I'm using the CAKEPHP 3 framework and i want to update a row(entity) in a table only if a change detected(automatically). Eg.: $id = 1; // debug($this->request->data) $this->request->data = ['id' => 1, 'name' => "My Name", 'content' => "My Content"]; // Inside the ArticlesController...

SQLite Database Update Needs Application to ReOpen to Actually Show New Values

android,sql,sqlite,sql-update,android-cursor
public void updateRow(int form_no, String form_name, String question_name, String answer_1, String answer_2, String answer_3, int answer_1_count, int answer_2_count, int answer_3_count) { String sql = "UPDATE " + DATABASE_TABLE + " SET " + KEY_ANSWER_1_COUNT + " = " + answer_1_count + ", " +KEY_ANSWER_2_COUNT + " = " + answer_2_count...

How to update nothing in an update fuction in PHP?

php,sql-update
I have a form where user details are updated. Once the page uploads the user will get a few fields loaded with the current database values. I can allow them to upload images, but it's optional. Once the form is submitted all fields are updated but the problem is with...

Update prices in mysql

mysql,sql,sql-update,sql-insert
This is how my articles table looks like: (tbl_articles) ID | SHORT_DESCRIPTION | DESCRIPTION | GROSS | NET 1 | v00556 | valve washroom | 9.00 | 7.49 etc. My supplier provided me a new price list, in this format (tbl_supplier) SHORT_DESCRIPTION | DESCRIPTION | GROSS | NET v0056 |...

SQL Error: ORA-00933: SQL command not properly ended in Oracle Update query

sql,oracle,sql-update
I have SYSTEM_SQL_CHECK table in which i have saved sql in CHECK_SQL column. This column is Varchar data type. Now i want to update particular sql.I have written below update sql query but it gives an error SQL Error: ORA-00933: SQL command not properly ended. I also tried to query...

Optimizing an update statement - Teradata

optimization,sql-update,teradata,spool
I'm trying to run the below update, but continue to run into spool space issues. Is there any way I can optimize? UPDATE dp_wedw_snd.platinumsaves SET package_name = (SELECT package_name FROM dp_wedw_snd.selfpaysubs_agid_platsaves WHERE trim(dp_wedw_snd.platinumsaves.esn1) = trim(cast(dp_wedw_snd.selfpaysubs_agid_platsaves.esn as varchar(255))) and abs(dp_wedw_snd.platinumsaves.shortdate - dp_wedw_snd.selfpaysubs_agid_platsaves.dateasof) = (select min(abs(dp_wedw_snd.platinumsaves.shortdate -...

Meaning of characters and symbols of T-SQL syntax

sql-server,tsql,syntax,sql-update,special-characters
Below is the syntax for the UPDATE statement in SQL Server. I guess in my past, I understood some of the symbols/characters in syntax definitions, but never really truly understood all of the symbols/characters mean with SQL syntax. Can someone help me understand what the following mean in the syntax...

Update SQL query, unsure why it isn't working as no errors are appearing

c#,sql,button,sql-update
I have been staring at this UPDATE statement for a long while and are unsure why my table isn't changing. When I press the button no error appears but my table doesn't not get updated either, I have checked that all of my variables have values on debug and they...

How do I fix function compilation error?

oracle,function,plsql,sql-update
--this is my function create or replace function sal_incr ( p_grade number) return number is v_inc number; begin select raise_percent into v_inc from sal_inc where grade_id in (select grade_id from emp_task where grade_id = p_grade); return v_inc; end; -- Update statement update emp_task set sal = sal + sal_incr(grade_id); --...

How to UPDATE all columns of a record without having to list every column

sql,sql-update
I'm trying to find out if there is a way to update a record without having to list every column name that is to be updated. For instance, it would be nice if I could use something similar to: // the parts inside braces are what I am trying to...

Update column with String prefix

sql,sql-update,oracle-sqldeveloper
Im triying to UPDATE a column named INV_SUPPLIER, I must add ES prefix to INV_SUPPLIER if the column does not start with ES AND does not contain NO_VALIDO AND IS NOT NULL Column declaration: Nullable Default INV_SUPPLIER VARCHAR2(32 BYTE) Yes When I select: SELECT * FROM EFAC_INVOICE f WHERE f.INV_SUPPLIER...

Mysql update using select

mysql,sql,sql-update
I'm trying to update the fields by using below query. What is the error in below query ? MySQL said: Documentation 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 orders...

Why do these queries return differently?

sql,sql-server,sql-update,subquery,isnull
I am working on a query which I am updating a user defined table that always has 1 row (it's part of a much larger operation). This table is populated by querying from a larger employee table based on employee ID. This query is working most of the time but...

Nested SQL with Coalesced data part of an update statement

sql-server,join,sql-update,concat,coalesce
I have the following set up create table #work ( customer_no int, attended_conf varchar(100) -- ADDED LR 6/16/15 ) The #work table is filled - customer_no is filled, attend_conf is null until a later update statement. What I would like to do is update the attended_conf field with the concatenated...

How to update multiple columns in the same table with the same sub-query in Oracle SQL

oracle,sql-update,subquery
Is there a better way of writing this general type update in Oracle: UPDATE table1 SET c1 = ( SELECT d1 FROM table2 WHERE table1.id = table2.id ), c2 = ( SELECT d2 FROM table2 WHERE table1.id = table2.id ) The update above is only an example. The sub-select could...

Update table with a sequence of values

sql,oracle,sql-update
I'm looking for a way to update an existing table with an ascending sequence of dates. Using this select works: SELECT TO_DATE('01-MAR-15') + (rownum * 2) FROM all_tables WHERE rownum <= 35 I cannot, however, use this in an update query. In Oracle, how could I write an update table...

MySQL: Update user record with value from next user record

mysql,sql-update
I have a table which looks like this: ID | uid | vcode | vcode_next 1 1 abc 2 2 def 3 2 ghi 4 1 jkl 5 1 mno and I need to update vcode_next with the next vcode for a given user ID. So the result should be:...

how can I update a list of records in a table with the new value depending on the old value

sql-server,sql-update
I have a table called acc1152 with the field accno. depending on what the value of this field is, i need to replace it with a new value. these are the values i need to update old value new value 7007 4007 7008 4008 4008 7 7009 4009 7011 4011...

Update query in oracle

sql,oracle11g,sql-update
I need to update all gmail.com email id in the table emails to yahoo.com. I have this below query which doesn't works. Can someone help? update emails set email = (select CONCAT(email, '@yahoo.com ') "email" from emails ) where email like '%@gmail.com%' ...

how to populate a table's fields with multiple values depending on the row

mysql,sql-update,populate
I have a table called sinvent with columns accno, jno, and saccno. jno and saccno are already filled with numbers, alot of the numbers repeat.i need to populate accno with the following values based on which jno its associated with. how do i write a single query to do this?...