323 questions
0
votes
0
answers
39
views
Multiple widget used same key
I have a persistent navbar component for navbar. Getting duplicate key error when logout and login. if we switch tab error is gone
════════ Exception caught by widgets library ═════════════════════════...
1
vote
0
answers
50
views
Duplicate GlobalKey detected in widget tree- Flutter
I am using formkey in my screen and I am not reusing it anywhere . But getting following error on navigation. I am defining my formkey inside my viewmodel. Putting this inside view resolves problem. ...
0
votes
0
answers
93
views
MariaDB Is there a syntax to update the values with ONDUPLICATE without having to rewrite all columns
I have to update a existing record e.g.
INSERT INTO table_name (column1, column2, column3)
VALUES (value1, value2, value3)
ON DUPLICATE KEY UPDATE
column1 = VALUES(column1),
column2 = VALUES(...
0
votes
0
answers
91
views
Duplicate Session Entry and Missing Session Support
I'm building a Discord bot dashboard API using NestJS, Passport, and TypeORM for session management. When a user attempts to log in through Discord, I encounter two errors:
[Nest] 19524 - 09.08.2024 ...
0
votes
1
answer
554
views
How to retrieve ids of inserted or updated rows after "INSERT ON DUPLICATE UPDATE" MySQL?
I'm storing players of my game based on their level :
CREATE TABLE IF NOT EXISTS Player(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(255) NOT NULL UNIQUE,
level TINYINT UNSIGNED ...
0
votes
0
answers
37
views
Update on duplicate with condition to check only ONCE to reduce I/O operations
I'm using Mysql query like this:
INSERT INTO test
(id, name, customerId, timestamp, status, lastTimestamp, testId, testCapacity)
values(1, 'test1', 2, 1717415401000, 'SAFE', 1717415401000, '...
0
votes
1
answer
57
views
php 8.1 + mysql 5.7: error handler in stored procedure dosen't work
I have a stored procedure with which I try to insert some data into two tables but I don't want to insert duplicate keys. So I wrote the following procedure with the handling of error 1062: duplicate ...
0
votes
1
answer
68
views
C# - ExecuteNonQuery does not return the right affectedRows on an INSERT with an ON DUPLICATE clause
Using HeidiSQL, I update a table with multiple duplicates using this query:
INSERT INTO ach_progress (user_id, app_id, ach_name, unlock_time)
VALUES (123456, 123456, '3', '2024-04-23 13:59:31'),
...
0
votes
1
answer
67
views
Google sheets: How to merge two Google sheets with duplicate keys?
I have two sheets, each containing a table with duplicate keys. I want to create a third sheet that merges these two tables such that each row represents a cross-product of the data for each key.
Here'...
0
votes
2
answers
65
views
Update scenario is not working properly when using CASEs or IF statement ON DUPLICATE KEY UPDATE section in MySQL
I need to do bulk insert and update on MySQL so I used the ON DUPLICATE KEY UPDATE. I need to ignore the updated by and updated date fields as existing old data if there are no changes in those record'...
-1
votes
3
answers
72
views
Mysql on duplicate key condition (IF) setting of one field
I am using on duplicate key to update data in a mySQL DB v 8.0.35 (AWS RDS instance)
I want to update a selection of fields with the new value. Plus set a further field (up[dated) to 1 only if a ...
0
votes
1
answer
73
views
How to get list of created/updated indexes from INSERT INTO with ON DUPLICATE KEY UPDATE in SP [MySQL 8.0.36]
How does one get a list of the record IDs created or updated when an INSERT INTO with ON DUPLICATE KEY is used - within the very stored procedure that executes the INSERT?
For example, such an action ...
0
votes
1
answer
47
views
mysql ON DUPLICATE KEY UPDATE, check 2 columns at a time
Let's say there are 4 columns in my table
ID int(11) AI PK
BANK_ID int(11)
BANK_BRANCH_CODE varchar(255)
BANK_BRANCH_NAME varchar(255)
I want to UPDATE the BANK_BRANCH_NAME if the combination of ...
0
votes
0
answers
25
views
MySQL ON DUPLICATE KEY UPDATE not working as expected [duplicate]
I have a table looking something like this
id (Primary Key, Auto increment)
user_type
name
some_column
1
Type 1
Name 1
Some value 1
2
Type 2
Name 2
Some value 2
I want to utilise ON DUPLICATE KEY ...
-2
votes
1
answer
63
views
SQL copy and paste table data into that same table by only changing one value
I want to copy and paste table data into that same table by only changing one value
Example: BillingLocationID
It's not possible to do it one by one inserting there are large number of rows.
I've ...
5
votes
4
answers
377
views
How to add prefix/suffix on a repeatable dictionary key in Python
Could you please suggest is there any way to keep all the repeatable (duplicate) keys by adding prefix or suffix. In the below example, the address key is duplicated 3 times. It may vary (1 to 3 ...
0
votes
1
answer
112
views
How to get actual value for duplicate index MongoDB?
I am interacting with MongoDB using C# driver. It threw duplicate key error like below for one index
the highlighted value 0x141214141a24 is not a actual value in the error message of location.path. ...
0
votes
0
answers
194
views
SQL MERGE INTO vs UPDATE with not exists
I'm trying to run an update query on this table to change any reference of 'YYY' to 'XXX' for COL1 while ignoring any rows that have already been updated this way. COL1 AND COL2 are primary keys. Is ...
-2
votes
1
answer
50
views
mysql version 5.7.39 query problem condition with on duplicate
hi everyone i need help
create table wishlist
(
userID int null,
wishlistData longtext collate utf8mb4_bin not null,
constraint userID
unique (userID)...
0
votes
2
answers
240
views
MariaDB INSERT - How can I increment a counter on duplicates?
I am writing event-log data to a MariaDB database. The primary key includes the time to one-second granularity. I sometimes get bursts of identical input data. This violates the key and is ...
0
votes
1
answer
972
views
Operand should contain 1 column(s) when trying to update one column
I have a table2 which has a composite primary key built from two columns, one of which is a foreign key from another table called table1, and the other is called position.
The table has a third column ...
0
votes
0
answers
24
views
mysqlpp's (Tangensoft) insertfrom with ON DUPLICATE KEY UPDATE
I searched a lot in the docs, but can't find an example or explanation upon the (detailed!) usage of Query::InsertPolicy in conjunction to the mass insertion function "insertfrom()".
It just ...
0
votes
1
answer
118
views
Optimize MySQL on duplicate key update with conditions to update
I have a working solution, but I'm not sure this might be the best solution.
My goal: there's a table (testtable) with a column status. When the current status is 'CXL' and a insert query is run, the ...
1
vote
2
answers
75
views
Should primary key columns be added in the UPDATE?
In the example code below, col1 and col2 are primary keys in the database!
My question is: should they be added in the part of the code after the ON DUPLICATE KEY UPDATE, as it is already in the code, ...
0
votes
0
answers
125
views
On Duplicate Key Update with Greatest Value
I have 4 rows in my SQL table. id, tokenid, score and time.
If a player is playing the game for the first time, I can save it to the database.
If a player replays and collects more points than when ...
1
vote
1
answer
3k
views
how to handle INSERT on conflict in a has many association in GORM Create, ERROR (SQLSTATE 23505)
I have two models as follows:
type OHLCV struct {
gorm.Model
Interval string `gorm:"uniqueIndex:idx_ohlcv"`
Pair string `gorm:"uniqueIndex:...
1
vote
1
answer
853
views
How to fix VALUES() deprecation notice in INSERT, ON DUPLICATE KEY UPDATE in MYSQL
VALUES() gives a deprecation notice in mysql 8.0 when used in a query like this
INSERT INTO foo (bar, baz) VALUES (1,2)
ON DUPLICATE KEY UPDATE baz=VALUES(baz)
This post showed how to fix it if you ...
0
votes
1
answer
754
views
Find Duplicate Key Value pairs across all JSON Objects in a JSON file
I have a JSON file like
{
"object1": {
"key_1": "value_1",
"key_2": "value_2",
"key_3": "value_3"
}...
2
votes
1
answer
332
views
Pandas: Split dataframe with duplicate values into dataframe with unique values
I have a dataframe in Pandas with duplicate values in Col1:
Col1
a
a
b
a
a
b
What I want to do is to split this df into different df-s with unique Col1 values in each.
DF1:
Col1
a
b
DF2:
Col1
a
b
DF3:
...
0
votes
1
answer
2k
views
INSERT ... ON DUPLICATE KEY UPDATE causes Deadlock Exception in Mysql 5.7
We are having a mysql table like below
CREATE TABLE student_subject (
student_subject_id int(11) NOT NULL AUTO_INCREMENT,
student_id int(11) NOT NULL,
subject_id int(11) NOT NULL,
version int(...
0
votes
0
answers
114
views
MYSQL PARTITIONS BY TIMESTAMP COLUMN
I have table with partitions by timestamp column (milliseconds). Theoretically it is unlikely to coincide, but can make the case that 2 inserts try to made with the same timestamp. Obviously it would ...
0
votes
2
answers
571
views
How to insert into table a new row then do nothing if already exists(without UNIQUE key)
Let's say I have these two tables. Where I insert employees to employee table coming from the staging table.
staging table:
id
employee_id
name
1
12
Paul
2
13
Kyle
employee table
id
employee_id
name
5
...
0
votes
0
answers
18
views
ON DUPLICATE KEY UPDATE - How to check if a row has been updated then trigger a column to insert modified date? [duplicate]
I insert my data using INSERT INTO SELECT then I have ON DUPLICATE KEY UPDATE like this:
ON DUPLICATE KEY UPDATE
first_name = COALESCE(eb.first_name, employee.first_name),
middle_name = ...
1
vote
1
answer
1k
views
PHP MySQL prepared statement: procedural Insert / update example [duplicate]
I struggle to understand prepared statements in PHP to allow users to edit a MySQL-database.
The user input is UTF-8, typical examples are the name in Arabic, Chinese, ... It also generates a problem ...
-1
votes
2
answers
721
views
How do i increment a value of column with condition?
my table looks something like this
id effect1(int) effect2(int) effect3(int)
1 0 1 5
2 1 0 0
i have a function, which return 1to3 int value ...
0
votes
1
answer
55
views
ON DUPLICATE KEY UPDATE not working in online sql editors
I'm learning SQL by using online code editors that can run the code, e.g. techonthenet.com or w3schools. The problem is, ON DUPLICATE KEY UPDATE command doesn't seem to work in those editors. Here's a ...
2
votes
1
answer
2k
views
on duplicate key update in snowflake
How can I use insert statement with on duplicate key update like MySQL in Snowflake?
MySQL code :
INSERT INTO table (column_list)
VALUES (value_list)
ON DUPLICATE KEY UPDATE
c1 = v1,
c2 = v2,
...
4
votes
1
answer
5k
views
INSERT INTO … ON DUPLICATE KEY UPDATE …. with condition?
I am still wondering if there is something like a conditional on duplicate update in MySQL 5.7
I have a table which is updated by different sources.
Let’s assume I have a table
CREATE TABLE t
(
...
0
votes
0
answers
79
views
Does ON DUPLICATE KEY UPDATE in MySQL cause extra disk space to be used?
We have a large table (around 100 million rows) that is often written to, and often updated rapidly (think an app that auto-saves state every x seconds).
All writes to this table currently do INSERT .....
2
votes
1
answer
914
views
Duplicate key error when updating key field in a set of records
I have a master detail relation between two tables. Troq is the master table and Troq_Alma is the detail table. Troq_Alma primary key is formed by Troq primary key (Troq.cod) and "Num_Orden&...
0
votes
1
answer
745
views
MySQL ON DUPLICATE KEY UPDATE in NodeJS
I'm using NodeJS with MySQL and async/await statements. I've got a UNIQUE column in a MySQL table named audioid.
I need to check if an audioid exists. If so I need to update a row. If not I need to ...
0
votes
1
answer
164
views
MySQL merge data on duplicate key
I'm adopting dashboard now and I created two tables for selecting from frontend;
DATA_SELECTED_HISTORY
DATA_SELECTED_NOW
My frontend page get data from DATA_SELECTED_NOW and my backend algorithm put ...
0
votes
2
answers
79
views
on duplicate key with a where condition
I am trying to use a WHERE condition on an INSERT INTO statement that contains ON DUPLICATE KEY. An example of what I'm trying to achieve is below.
This SQL statement is being called by third-party ...
3
votes
1
answer
3k
views
bulk insert sqlalchemy core with on conflict update
I want to insert multiple items into a table and upsert the table on conflict. This is what I came up with the following
from sqlalchemy.dialects.postgresql import insert
meta = MetaData()
jobs_table =...
0
votes
0
answers
127
views
How to insert...on duplicate key update (MySQL) after a condition same as IF() condition
I am implementing a situation when the INSERT ...ON DUPLICATE KEY UPDATE needs to be executed only after an IF condition is satisfied.
I am having issues on how to include the condition statement. ...
0
votes
0
answers
53
views
MySQL INSERT INTO ON DUPLICATE KEY UPDATE FROM DIFFERENT TABLE
I'm using node.js with MySQL and i have two table like Bookings and Places to make a parking API
I'm trying to book a place on Table Bookings and update field Places.isAvailable (type Boolean) in a ...
0
votes
0
answers
194
views
MySQL INSERT INTO ON DUPLICATE KEY UPDATE non sequential id
I have this table:
CREATE TABLE `test` (`id` INT(11) NOT NULL AUTO_INCREMENT , `name` VARCHAR(100) NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB;
| id | name |
| -- | ---- |
In which I insert the ...
0
votes
1
answer
126
views
Update fields for MySQL Insert ... On Duplicate Key Update
I have a somewhat long MySQL ETL statement where I am inserting 32 columns of data into a table. This ETL statement is also utilizing UNION as a derived table.
My code is similar to this, as defined ...
0
votes
1
answer
58
views
unique objects by value and extra filter within an array of objects
I am trying to get unique objects within an array of objects. Let's say the object is like below.
values = [
{ id: 10, available: true },
{ id: 10, available: false },
{ id: 11, ...
0
votes
1
answer
252
views
Error when inserting record into mysql table
I have created the following table:
CREATE TABLE IF NOT EXISTS `prices_1d` (
`symbol` char(50) NOT NULL,
`open_time` datetime DEFAULT NULL,
`open` decimal(15,8) unsigned DEFAULT NULL,
`high` ...