Skip to main content

All Questions

Tagged with
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'...
Mohanraj Periyannan's user avatar
-1 votes
1 answer
44 views

If I have multiple entries in a cloumn in mysql that need to be changed

So I want to change all the fields in the column allow_two_day_ordering to False. How can I change them all without doing it one by one. I have a much bigger list than this. +-------+------------------...
Singleton's user avatar
  • 113
0 votes
1 answer
40 views

How can I UPDATE a column in a record when that information is the result of a GROUP CONCAT in the same table?

I cannot determine if this should be something nested or a JOIN. Each record has three values from the column value across from their name in the column variable. I have a successful GROUP CONCAT that ...
thirtywest's user avatar
0 votes
1 answer
61 views

How to improve this INSERT code with ON DUPLICATE KEY UPDATE

I had this code: for chunk in np.array_split(DataFrame, 20, axis=0): for i in chunk.index: cursor.execute("INSERT INTO table (col1, col2, col3, col4) VALUES (%s, %s, %s, %s) ON ...
Angel's Tear's user avatar
1 vote
2 answers
58 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, ...
Py Ton's user avatar
  • 43
0 votes
0 answers
61 views

MYSQL SELECT statement failing within an UPDATE, within a LOOP

I am writing a stored procedure to update a company calendar. The calendar data is stored within a MYSQL table. The stored procedure is an insert function which should force all calendar events ...
Luke Krell's user avatar
0 votes
1 answer
1k 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(...
Syedsulaiman M's user avatar
1 vote
0 answers
27 views

What is the most efficient way to update the value of another table in MYSQL?

Scenario 1. Two tables exist called 'score_log' and 'games_played_count' 2. Computing the "count" of rows from score_log that uniquely describe the number of games that have been played by a ...
Andy's user avatar
  • 11
0 votes
1 answer
267 views

Error creating Trigger After Insert in Mysql

I'm stuck when creating my trigger in mysql (on phpmyadmin), and that's why I come to ask for your help I have 2 tables : Assemblage and Bicyclette. Tables Diagram: Assemblage was built like this : ...
cowbra's user avatar
  • 23
-1 votes
1 answer
97 views

How to INSERT INTO SELECT by considering IF EXISTS rules in MySQL? [duplicate]

In MySQL its possible to insert data retrieved from another table, e.g.: INSERT INTO `table2` ( `table2_id`, `foo` ) SELECT `id`, `foo` FROM `table1` WHERE ....
automatix's user avatar
  • 14.9k
-1 votes
1 answer
129 views

UPDATE NULL of a column matching the ID in the same table

I'm working on housing data with several columns. In the cleaning process, I noticed that in the column 'PropertyAddress' are a few Null, and I want to confirm if those Null could be matched with the ...
Alex's user avatar
  • 3
0 votes
0 answers
279 views

How to Convert SQL Server Query to MySQL Query

I'm trying to convert this SQL Server query to MySQL query how can i do that? Fallowing is my SQL server query. I need to convert this query to execute in MySQL. EpfNO is the Primary key and ...
Damith Dulanjana Dissanayaka's user avatar
0 votes
0 answers
45 views

INSERT or UPDATE : importing data and managing update

I face an insolvable issue (for me). I have a client table CREATE TABLE `client` ( `cli_id` INT NOT NULL, `cli_active` SMALLINT NOT NULL DEFAULT 1, PRIMARY KEY (`cli_id`)); According that we ...
Groco's user avatar
  • 1,321
0 votes
1 answer
194 views

MySQL while loop insert

I am facing a very strange problem with while loop insert on MySQL Here's the background information of my test: CREATE TABLE test_table ( `token` varchar(16) NOT NULL, `val1` varchar(256) DEFAULT ...
Drake Orfeo's user avatar
0 votes
1 answer
46 views

Inserting 0s for dates currently without data, after a key's first appearance

I've got a table that looks something like the following Date Key Metric 2021-01-31 A 6 2021-02-28 A 3 2021-05-31 A 3 2021-03-31 B 4 2021-04-30 B 1 2021-05-31 B 2 What I'd like to do is insert ...
kpdawson24's user avatar

15 30 50 per page
1
2 3 4 5
25