on-duplicate-key Questions
4
Solved
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 ti...
Miraculous asked 17/8, 2023 at 16:18
7
Solved
I am working on a Yii project. How can I use the ON DUPLICATE feature of MySQL ( http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html ) when doing a save() on a Yii model?
My MySQL is a...
Sivie asked 25/1, 2012 at 14:26
3
Solved
For loading huge amounts of data into MySQL, LOAD DATA INFILE is by far the fastest option. Unfortunately, while this can be used in a way INSERT IGNORE or REPLACE works, ON DUPLICATE KEY UPDATE is...
Pachton asked 7/3, 2013 at 12:25
9
Solved
I've searched around but didn't find if it's possible.
I've this MySQL query:
INSERT INTO table (id,a,b,c,d,e,f,g) VALUES (1,2,3,4,5,6,7,8)
Field id has a "unique index", so there can't be two ...
Shakhty asked 17/1, 2013 at 16:21
5
Solved
I am currently having problems with a primary key ID which is set to auto increment. It keeps incrementing ON DUPLICATE KEY.
For Example:
ID | field1 | field2
1 | user | value
5 | secondUser | ...
Colocynth asked 13/7, 2016 at 9:1
3
Solved
I'm working on migrating a database and I'm not sure why I'm getting this error. Does anyone know how to fix this? Before this, I created a new database using mysql and granted access to users. I h...
Claire asked 4/1, 2016 at 19:13
5
Solved
I know that you can use ON DUPLICATE KEY UPDATE to update a certain value if there is a record for that key already,
I can do this:
INSERT INTO `tableName` (`a`,`b`,`c`) VALUES (1, 2, 3)
ON DUPLI...
Smidgen asked 2/3, 2012 at 17:29
3
Solved
I've a table folio with timestamp set to auto update.
CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
PDO statement in PHP is not causing the timestamp to update.
$statement = $this->connectio...
Holdback asked 9/6, 2014 at 21:1
2
Solved
I understand that there exists INSERT IGNORE and INSERT ... ON DUPLICATE KEY UPDATE. However, when there is a duplicate key, I'd like to do a INSERT to a temporary table to keep a record of the uni...
Dessert asked 13/8, 2012 at 18:55
1
I have many rows of data to be inserted into a table. Table already has data in it. When I do a bulk insert like this,
INSERT INTO permission(username, permission) values(('john','ticket_vie...
Crossman asked 11/12, 2018 at 10:45
9
Solved
How can I write an INSERT doctrine query with option ON DUPLICATE KEY UPDATE?
Amari asked 29/12, 2010 at 15:23
2
Solved
What I actually want is to write following query in JOOQ:
stmt = connection.prepareStatement(
"INSERT INTO `tbl` (`name`, `service_id`, `device_id`) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE `id` ...
Highpressure asked 19/10, 2014 at 6:25
1
I've read from this source that you can do an insert on dupcliate key ignore in postgres, but I cannot seem to get this to work for a select from:
link
What I've seen you can do is:
insert into ...
Lipp asked 2/2, 2017 at 5:31
2
Solved
I have several classes that I need to derive from a common base class which holds an Id. Ignoring the all but one of these for the moment, let's say we have:
public class MyBase {
[Key]
public i...
Kinelski asked 18/4, 2014 at 4:42
4
Solved
I have a statement that tries to insert a record and if it already exists, it simply updates the record.
INSERT INTO temptable (col1,col2,col3)
VALUES (1,2,3)
ON DUPLICATE KEY UPDATE col1=VALUES(c...
Outspan asked 13/6, 2013 at 12:13
1
Solved
I want to implement a Viewed system for my website. Here is the structure of my tables:
// table1
id | user_or_ip | post_id | date_time // inserting new row for each viewed
// table2
id | post_id...
Phylis asked 19/11, 2015 at 14:3
1
Solved
Can I safely update all values like this:
INSERT INTO tbl_name SET `a`=:a, `b`=:b, ... `z`=:z
ON DUPLICATE KEY UPDATE
`a`=VALUES(`a`), `b`=VALUES(`b`), ... `z`=VALUES(`z`);
I have tried it, and ...
Homophony asked 24/8, 2015 at 10:19
1
Solved
I am executing SQL (MySQL) commands from PHP. There are several possible outcomes to each execution:
Record updated to new value
Record updated, but values happen to be the same
Record finds no r...
Bourdon asked 20/4, 2015 at 21:6
2
Solved
What is the method to do multi insert of values into SQL Server database? Usually in MySQL I use queries like:
INSERT INTO table (column1, column2)
VALUES(value1, value2), (value3, value4)
ON DUPLI...
Aaronaaronic asked 8/4, 2014 at 0:51
2
Solved
Here is what I am trying to do. I want to insert into this table or update the record if the primary key(entity_id) exists. I am just having an issue with the SQL syntax. It wont let me have more p...
Gery asked 2/4, 2013 at 19:54
2
Solved
I'd like to switch PDO INSERT and UPDATE prepared statements to INSERT and ON DUPLICATE KEY UPDATE since I think it'll be a lot more efficient than what I'm currently doing, but I'm having trouble ...
Motivation asked 30/12, 2012 at 7:29
2
Solved
I have a table playerspoints that contains a shop id and a player's id, and a player's points.
SHOP_ID | PLAYER_ID | POINTS
----------------------------------------
1 | 7 | 66
2 | 4 | 33
What ...
Torrance asked 20/11, 2012 at 4:34
2
Solved
I have a basic table with columns:
id (primary with AI)
name (unique)
etc
If the unique column doesn't exist, INSERT the row, otherwise UPDATE the row....
INSERT INTO pages (name, etc)
VALUES
...
Atwell asked 8/2, 2012 at 7:6
2
Solved
I have no idea if this is even remotely correct. I have a class where I would like to update the database if the fields currently exist or insert if they do not. The complication is that I am doing...
Psia asked 28/7, 2011 at 1:27
1
© 2022 - 2024 — McMap. All rights reserved.