FAQ Database Discussion Community


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...

add subitems to meteor document

mongodb,meteor,collections,insert-update
I have a meteor collection "list" that has the following data structure. "list" : [ { "_id" : "id", "author" : "authorId", "createdOn" : "DateTime", "description" : "description", "items" : [ { "item1" : { "itemComplete" : "Boolean", "itemName" : "item name", "itemDescription" : "item description", } }, { "item2"...

Using Core Data Find or Create Pattern in Generic Method

ios,core-data,insert-update
I have a Generic method which adds data from a JSON into a Managed Object based on the keys in the JSON and in the entity. I have read Apple's documentation here but I somehow can't seem to walk through the data after the fetch in order to apply the...

How to update multiple columns in one row using android sqlite database?

java,android,database,sqlite,insert-update
I have an android application that stores location data. There are three set of Latitude and Longitude in SQLite database. I want to take a location's data 3 times and store it to the database. In my first step stores Place, Location address, Latitude and Longitude. Second step without changing...

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...

Delete duplicated rows from my database + Make sure no more duplications will be added

php,mysql,database,insert-update,on-duplicate-key
I know alot of people asked this question before but I didn't find an absloute answer and I saw alot of different answers so i'm confused. I'v got the following data for example in my sql database: user: test code: blablah email: [email protected] user: zeus code: olympus email: [email protected] user:test...

How to insert an alternative value from an old table into a new table IF NULL.

sql,insert-update,ifnull
I have this old_table. ID: First_name: Last_name: Age: 1 Christian Johnson 25 2 John Christiansen 21 3 <NULL> Peterson 23 and this new_table I just created, by this piece of code: CREATE TABLE new_table (ID integer, name text, age text); INSERT INTO new_table (ID, name, age) SELECT ID, First_name, age...

Insert/ Update Scalability (searching increasingly longer list for update match untenable)

mysql,sql,scalability,insert-update
Haven't found a clear answer to this here. I'm performing a basic "Insert/ Update' -- funneling new data into a MySQL database of "Tickets." For example: ticket_id: 154 status: open messages: 2 That would be a ticket in the DB. An incoming record would either insert/ update based on the...

mysql insert records challenge

mysql,insert-update
I have a table that contains topsores of 21 teams. Most of the teams have 5 topscores, but some have 4. For the teams with 4 scores, one needs to be added, being a copy of the worst score. So in the example below for team 1 a copy of...

kdb+ conditional insert: only insert when column value doesn't exist

insert-update,kdb,dotq
What is the best way to insert a row into a table, only if a column of that row doesn't exist in the table. E.g.: q)table:([] col1:(); col2:(); col3:()); q)`table insert (1;2;3); q)conditionalInsert:{if[first where table.col1=x(0)~0N;`table insert x]}; Now when doing the following: q)conditionalInsert[(1;2;3)]; q)conditionalInsert[(7;8;9)]; The result yields: q)table col1 col2...

How to use update() in meteor to insert new variable in existing document

meteor,insert-update
I want to add new variable in the existing DB Document. I am using nodeDB.update( this._id,{$set:{'activeTemplate':1}}); However on the click of the submit button , the other values become null. What Am I doing wrong?...

Access database syntax error in update into statement

c#,database,ms-access,syntax-error,insert-update
First of all I know password is a reserved type of Access Database. But I have read a post that you can put [password] like that and it will work. But its not working. I have tried many ways and still, I hope that some one will help. OleDbCommand cmd...

How to create trigger to change status after insert and update in MySQL?

mysql,date,triggers,insert,insert-update
i have a table (input) with some fields : check_number int (primary key) name varchar(20) nominal int date1 date date2 date status varchar(20) i want to make trigger with these condition : if i insert data in input_table then status will change into (Unpaid) automatically (which is date2 is null...

Insert record if user_id is unique in table, if not update column

php,mysql,pdo,insert,insert-update
I need to INSERT record if user_id is unique in table map, but if not then UPDATE that row where user_id=:user_id with data... What I try: try { $result = $db->prepare('SELECT user_id FROM map WHERE user_id=:user_id'); $result->bindParam(':user_id', $user_id); $result->execute(); //echo $jsonTable; } catch(PDOException $e) { echo 'ERROR: ' . $e->getMessage();...

SQL inserts slow - “pre populate with blank rows??”

sql-server,performance,sql-update,sql-insert,insert-update
I have an .exe that compares a vbTab delimited .txt file with an SQL table. Updates to the table's existing records goes very fast. Inserts into the table for new records is quite slow. As I'm new to SQL, I'm wondering if my idea is crazy talk: I thought that...

How to insert new data if user_id does not exist in mysql table

php,mysql,pdo,insert-update
I have two columns into mysql table map 1. First column have name json, second have name user_id Now, I need to insert data to new row if user_id does not exist into mysql table, but if excist I need just to update json column where user_id = user_id ......

Retrieving the highest-frequency value from a field in one table and updating it into another

mysql,database,insert-update
I have 2 MySQL tables with the following structure: **tblLocations** ID [primary key] CITY [non-unique varchar] NAME [non-unique varchar] ---------------------------------- **tblPopularNames** ID [primary key] CITY [unique varchar] POPULARNAME [non-unique varchar] I am receiving input from users through a web form and a PHP code is then inserting the data into...

My SQL Simple Query Error

java,mysql,insert-update
I am new at MYSQL,I wrote simple query as follow: CREATE Table tblFeedBack ( `FeedBackID` INT AUTO_IncremeNT, `UserID` INT, `Inserted_TS` TIMESTAMP , `FeedBackValue` VARCHAR(100), PRIMARY KEY (FeedBackID) ); CREATE PROCEDURE tblFeedBack_InsertUpdate ( IN U_ID INT, IN FB_Value VARCHAR(50) ) BEGIN IF ((Select COUNT(*) From 'tblFeedback') < 3) BEGIN INSERT INTO...

Improving Speed of SQL 'Update' function - break into Insert/ Delete?

mysql,database,performance,optimization,insert-update
I'm running an ETL process and streaming data into a MySQL table. Now it is being written over a web connection (fairly fast one) -- so that can be a bottleneck. Anyway, it's a basic insert/ update function. It's a list of IDs as the primary key/ index .... and...