Questions tagged [on-duplicate-key]
ON DUPLICATE KEY UPDATE is an SQL feature in MySQL which allows a row to be updated instead on inserted in an INSERT query, if it would otherwise attempt to create a duplicate key in a unique index.
on-duplicate-key
316
questions
0
votes
1
answer
40
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
30
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
18
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
41
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
34
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
49
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
54
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
57
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
39
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
23
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
54
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
151
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
89
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
112
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
35
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)...