Why do Mysql return error code 1241 on Update query?
up vote
0
down vote
favorite
I'm using Mysql Workbench 8.0.12, I have a table (tblproduction) with three columns:
idProduction INT PK AI
dateProduction DATETIME
statusProduction VARCHAR(15)
When I try to change the value of the column statusProduction for example, from 'queue' to 'done' as the query below (SELECT, INSERT AND DELETE querys are OK):
UPDATE tblproduction
SET statusProduction = 'done'
WHERE idProduction=1;
The system returns "Error Code: 1241. Operand should contain 1 column(s)."
I've done some research and found out that this error code is related to syntax errors, but I didn't find any problem on my query.
If I try to do something like this:
UPDATE tblproduction
SET statusProduction = 'done'
WHERE idProduction='a';
The system actually run the query although 0 rows were affected, but it gave me the same error message if I try this instead:
UPDATE tblproduction
SET statusProduction = 'done'
WHERE idProduction='1';
I really don't know what is wrong, and I know it's a silly question but if anyone could help me.
mysql
|
show 2 more comments
up vote
0
down vote
favorite
I'm using Mysql Workbench 8.0.12, I have a table (tblproduction) with three columns:
idProduction INT PK AI
dateProduction DATETIME
statusProduction VARCHAR(15)
When I try to change the value of the column statusProduction for example, from 'queue' to 'done' as the query below (SELECT, INSERT AND DELETE querys are OK):
UPDATE tblproduction
SET statusProduction = 'done'
WHERE idProduction=1;
The system returns "Error Code: 1241. Operand should contain 1 column(s)."
I've done some research and found out that this error code is related to syntax errors, but I didn't find any problem on my query.
If I try to do something like this:
UPDATE tblproduction
SET statusProduction = 'done'
WHERE idProduction='a';
The system actually run the query although 0 rows were affected, but it gave me the same error message if I try this instead:
UPDATE tblproduction
SET statusProduction = 'done'
WHERE idProduction='1';
I really don't know what is wrong, and I know it's a silly question but if anyone could help me.
mysql
2
can you please provide the complete DDL for creating this table.
– Used_By_Already
Nov 19 at 3:09
The error message does not fit your query, but I would check if you have an update trigger on your table, it might contain incorrect code (that will only run when your where-condition leads to an actual update, so probably not forid='a').
– Solarflare
Nov 19 at 3:40
@Used_By_Already DDL statement as down below: CREATE TABLE IF NOT EXISTSmilani.tblProduction(idProductionINT NOT NULL AUTO_INCREMENT,dateProductionDATETIME NOT NULL,statusProductionVARCHAR(15) NOT NULL, PRIMARY KEY (idProduction))
– Fabricio Montagnani
Nov 19 at 23:56
These small comments are not the place to add code. We expect important information like that DDL to be added into the question (there is an edit link for that reason) and in the question it can be properly formatted.
– Used_By_Already
Nov 20 at 0:09
@Solarflare there is a UPDATE trigger indeed, that I've dropped for testing and got the same outcome... I dropped the entire database and created it again without creating the update trigger this time and the update statement did work this time, thank you! I'm going to work on the trigger now
– Fabricio Montagnani
Nov 20 at 0:23
|
show 2 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm using Mysql Workbench 8.0.12, I have a table (tblproduction) with three columns:
idProduction INT PK AI
dateProduction DATETIME
statusProduction VARCHAR(15)
When I try to change the value of the column statusProduction for example, from 'queue' to 'done' as the query below (SELECT, INSERT AND DELETE querys are OK):
UPDATE tblproduction
SET statusProduction = 'done'
WHERE idProduction=1;
The system returns "Error Code: 1241. Operand should contain 1 column(s)."
I've done some research and found out that this error code is related to syntax errors, but I didn't find any problem on my query.
If I try to do something like this:
UPDATE tblproduction
SET statusProduction = 'done'
WHERE idProduction='a';
The system actually run the query although 0 rows were affected, but it gave me the same error message if I try this instead:
UPDATE tblproduction
SET statusProduction = 'done'
WHERE idProduction='1';
I really don't know what is wrong, and I know it's a silly question but if anyone could help me.
mysql
I'm using Mysql Workbench 8.0.12, I have a table (tblproduction) with three columns:
idProduction INT PK AI
dateProduction DATETIME
statusProduction VARCHAR(15)
When I try to change the value of the column statusProduction for example, from 'queue' to 'done' as the query below (SELECT, INSERT AND DELETE querys are OK):
UPDATE tblproduction
SET statusProduction = 'done'
WHERE idProduction=1;
The system returns "Error Code: 1241. Operand should contain 1 column(s)."
I've done some research and found out that this error code is related to syntax errors, but I didn't find any problem on my query.
If I try to do something like this:
UPDATE tblproduction
SET statusProduction = 'done'
WHERE idProduction='a';
The system actually run the query although 0 rows were affected, but it gave me the same error message if I try this instead:
UPDATE tblproduction
SET statusProduction = 'done'
WHERE idProduction='1';
I really don't know what is wrong, and I know it's a silly question but if anyone could help me.
mysql
mysql
asked Nov 18 at 23:19
Fabricio Montagnani
12
12
2
can you please provide the complete DDL for creating this table.
– Used_By_Already
Nov 19 at 3:09
The error message does not fit your query, but I would check if you have an update trigger on your table, it might contain incorrect code (that will only run when your where-condition leads to an actual update, so probably not forid='a').
– Solarflare
Nov 19 at 3:40
@Used_By_Already DDL statement as down below: CREATE TABLE IF NOT EXISTSmilani.tblProduction(idProductionINT NOT NULL AUTO_INCREMENT,dateProductionDATETIME NOT NULL,statusProductionVARCHAR(15) NOT NULL, PRIMARY KEY (idProduction))
– Fabricio Montagnani
Nov 19 at 23:56
These small comments are not the place to add code. We expect important information like that DDL to be added into the question (there is an edit link for that reason) and in the question it can be properly formatted.
– Used_By_Already
Nov 20 at 0:09
@Solarflare there is a UPDATE trigger indeed, that I've dropped for testing and got the same outcome... I dropped the entire database and created it again without creating the update trigger this time and the update statement did work this time, thank you! I'm going to work on the trigger now
– Fabricio Montagnani
Nov 20 at 0:23
|
show 2 more comments
2
can you please provide the complete DDL for creating this table.
– Used_By_Already
Nov 19 at 3:09
The error message does not fit your query, but I would check if you have an update trigger on your table, it might contain incorrect code (that will only run when your where-condition leads to an actual update, so probably not forid='a').
– Solarflare
Nov 19 at 3:40
@Used_By_Already DDL statement as down below: CREATE TABLE IF NOT EXISTSmilani.tblProduction(idProductionINT NOT NULL AUTO_INCREMENT,dateProductionDATETIME NOT NULL,statusProductionVARCHAR(15) NOT NULL, PRIMARY KEY (idProduction))
– Fabricio Montagnani
Nov 19 at 23:56
These small comments are not the place to add code. We expect important information like that DDL to be added into the question (there is an edit link for that reason) and in the question it can be properly formatted.
– Used_By_Already
Nov 20 at 0:09
@Solarflare there is a UPDATE trigger indeed, that I've dropped for testing and got the same outcome... I dropped the entire database and created it again without creating the update trigger this time and the update statement did work this time, thank you! I'm going to work on the trigger now
– Fabricio Montagnani
Nov 20 at 0:23
2
2
can you please provide the complete DDL for creating this table.
– Used_By_Already
Nov 19 at 3:09
can you please provide the complete DDL for creating this table.
– Used_By_Already
Nov 19 at 3:09
The error message does not fit your query, but I would check if you have an update trigger on your table, it might contain incorrect code (that will only run when your where-condition leads to an actual update, so probably not for
id='a').– Solarflare
Nov 19 at 3:40
The error message does not fit your query, but I would check if you have an update trigger on your table, it might contain incorrect code (that will only run when your where-condition leads to an actual update, so probably not for
id='a').– Solarflare
Nov 19 at 3:40
@Used_By_Already DDL statement as down below: CREATE TABLE IF NOT EXISTS
milani.tblProduction ( idProduction INT NOT NULL AUTO_INCREMENT, dateProduction DATETIME NOT NULL, statusProduction VARCHAR(15) NOT NULL, PRIMARY KEY (idProduction))– Fabricio Montagnani
Nov 19 at 23:56
@Used_By_Already DDL statement as down below: CREATE TABLE IF NOT EXISTS
milani.tblProduction ( idProduction INT NOT NULL AUTO_INCREMENT, dateProduction DATETIME NOT NULL, statusProduction VARCHAR(15) NOT NULL, PRIMARY KEY (idProduction))– Fabricio Montagnani
Nov 19 at 23:56
These small comments are not the place to add code. We expect important information like that DDL to be added into the question (there is an edit link for that reason) and in the question it can be properly formatted.
– Used_By_Already
Nov 20 at 0:09
These small comments are not the place to add code. We expect important information like that DDL to be added into the question (there is an edit link for that reason) and in the question it can be properly formatted.
– Used_By_Already
Nov 20 at 0:09
@Solarflare there is a UPDATE trigger indeed, that I've dropped for testing and got the same outcome... I dropped the entire database and created it again without creating the update trigger this time and the update statement did work this time, thank you! I'm going to work on the trigger now
– Fabricio Montagnani
Nov 20 at 0:23
@Solarflare there is a UPDATE trigger indeed, that I've dropped for testing and got the same outcome... I dropped the entire database and created it again without creating the update trigger this time and the update statement did work this time, thank you! I'm going to work on the trigger now
– Fabricio Montagnani
Nov 20 at 0:23
|
show 2 more comments
3 Answers
3
active
oldest
votes
up vote
0
down vote
please try using this method :
I have created a table and inserted the record like this :
select * from tblproduction;
+--------------+---------------------+------------------+
| idProduction | dateProduction | statusProduction |
+--------------+---------------------+------------------+
| 1 | 2018-11-19 08:22:11 | queue |
+--------------+---------------------+------------------+
use update query :
UPDATE `test`.`tblproduction` SET `statusProduction` = 'done' WHERE `tblproduction`.`idProduction` =1;
got result :
--------------+---------------------+------------------+
| idProduction | dateProduction | statusProduction |
+--------------+---------------------+------------------+
| 1 | 2018-11-19 08:22:11 | done |
+--------------+---------------------+------------------+
add a comment |
up vote
0
down vote
I am unable to reproduce your problem, see https://rextester.com/OQI5184
#MySQL 5.7.12
#'\' is a delimiter
DROP TABLE IF EXISTS tblProduction;
CREATE TABLE IF NOT EXISTS tblProduction (
idProduction INT NOT NULL AUTO_INCREMENT
, dateProduction DATETIME NOT NULL
, statusProduction VARCHAR(15) NOT NULL
, PRIMARY KEY (idProduction)
)
;
INSERT INTO tblProduction(dateProduction,statusProduction) VALUES ('2018-11-20','start');
SELECT * FROM tblProduction;
UPDATE tblproduction
SET statusProduction = 'done'
WHERE idProduction=1;
SELECT * FROM tblProduction;
RESULTS:
+---+--------------+---------------------+------------------+
| | idProduction | dateProduction | statusProduction |
+---+--------------+---------------------+------------------+
| 1 | 1 | 20.11.2018 00:00:00 | start |
+---+--------------+---------------------+------------------+
+---+--------------+---------------------+------------------+
| | idProduction | dateProduction | statusProduction |
+---+--------------+---------------------+------------------+
| 1 | 1 | 20.11.2018 00:00:00 | done |
+---+--------------+---------------------+------------------+
add a comment |
up vote
0
down vote
So the problem wasn't neither the query nor the table, there was an update trigger on this table (witch I dropped for testing and didn't work), to sum up I had to drop the database and created it all once again without creating the trigger. This time the update query worked, I'm working on the trigger now to see if I can find what's wrong
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
please try using this method :
I have created a table and inserted the record like this :
select * from tblproduction;
+--------------+---------------------+------------------+
| idProduction | dateProduction | statusProduction |
+--------------+---------------------+------------------+
| 1 | 2018-11-19 08:22:11 | queue |
+--------------+---------------------+------------------+
use update query :
UPDATE `test`.`tblproduction` SET `statusProduction` = 'done' WHERE `tblproduction`.`idProduction` =1;
got result :
--------------+---------------------+------------------+
| idProduction | dateProduction | statusProduction |
+--------------+---------------------+------------------+
| 1 | 2018-11-19 08:22:11 | done |
+--------------+---------------------+------------------+
add a comment |
up vote
0
down vote
please try using this method :
I have created a table and inserted the record like this :
select * from tblproduction;
+--------------+---------------------+------------------+
| idProduction | dateProduction | statusProduction |
+--------------+---------------------+------------------+
| 1 | 2018-11-19 08:22:11 | queue |
+--------------+---------------------+------------------+
use update query :
UPDATE `test`.`tblproduction` SET `statusProduction` = 'done' WHERE `tblproduction`.`idProduction` =1;
got result :
--------------+---------------------+------------------+
| idProduction | dateProduction | statusProduction |
+--------------+---------------------+------------------+
| 1 | 2018-11-19 08:22:11 | done |
+--------------+---------------------+------------------+
add a comment |
up vote
0
down vote
up vote
0
down vote
please try using this method :
I have created a table and inserted the record like this :
select * from tblproduction;
+--------------+---------------------+------------------+
| idProduction | dateProduction | statusProduction |
+--------------+---------------------+------------------+
| 1 | 2018-11-19 08:22:11 | queue |
+--------------+---------------------+------------------+
use update query :
UPDATE `test`.`tblproduction` SET `statusProduction` = 'done' WHERE `tblproduction`.`idProduction` =1;
got result :
--------------+---------------------+------------------+
| idProduction | dateProduction | statusProduction |
+--------------+---------------------+------------------+
| 1 | 2018-11-19 08:22:11 | done |
+--------------+---------------------+------------------+
please try using this method :
I have created a table and inserted the record like this :
select * from tblproduction;
+--------------+---------------------+------------------+
| idProduction | dateProduction | statusProduction |
+--------------+---------------------+------------------+
| 1 | 2018-11-19 08:22:11 | queue |
+--------------+---------------------+------------------+
use update query :
UPDATE `test`.`tblproduction` SET `statusProduction` = 'done' WHERE `tblproduction`.`idProduction` =1;
got result :
--------------+---------------------+------------------+
| idProduction | dateProduction | statusProduction |
+--------------+---------------------+------------------+
| 1 | 2018-11-19 08:22:11 | done |
+--------------+---------------------+------------------+
answered Nov 19 at 7:44
Atul Akabari
954
954
add a comment |
add a comment |
up vote
0
down vote
I am unable to reproduce your problem, see https://rextester.com/OQI5184
#MySQL 5.7.12
#'\' is a delimiter
DROP TABLE IF EXISTS tblProduction;
CREATE TABLE IF NOT EXISTS tblProduction (
idProduction INT NOT NULL AUTO_INCREMENT
, dateProduction DATETIME NOT NULL
, statusProduction VARCHAR(15) NOT NULL
, PRIMARY KEY (idProduction)
)
;
INSERT INTO tblProduction(dateProduction,statusProduction) VALUES ('2018-11-20','start');
SELECT * FROM tblProduction;
UPDATE tblproduction
SET statusProduction = 'done'
WHERE idProduction=1;
SELECT * FROM tblProduction;
RESULTS:
+---+--------------+---------------------+------------------+
| | idProduction | dateProduction | statusProduction |
+---+--------------+---------------------+------------------+
| 1 | 1 | 20.11.2018 00:00:00 | start |
+---+--------------+---------------------+------------------+
+---+--------------+---------------------+------------------+
| | idProduction | dateProduction | statusProduction |
+---+--------------+---------------------+------------------+
| 1 | 1 | 20.11.2018 00:00:00 | done |
+---+--------------+---------------------+------------------+
add a comment |
up vote
0
down vote
I am unable to reproduce your problem, see https://rextester.com/OQI5184
#MySQL 5.7.12
#'\' is a delimiter
DROP TABLE IF EXISTS tblProduction;
CREATE TABLE IF NOT EXISTS tblProduction (
idProduction INT NOT NULL AUTO_INCREMENT
, dateProduction DATETIME NOT NULL
, statusProduction VARCHAR(15) NOT NULL
, PRIMARY KEY (idProduction)
)
;
INSERT INTO tblProduction(dateProduction,statusProduction) VALUES ('2018-11-20','start');
SELECT * FROM tblProduction;
UPDATE tblproduction
SET statusProduction = 'done'
WHERE idProduction=1;
SELECT * FROM tblProduction;
RESULTS:
+---+--------------+---------------------+------------------+
| | idProduction | dateProduction | statusProduction |
+---+--------------+---------------------+------------------+
| 1 | 1 | 20.11.2018 00:00:00 | start |
+---+--------------+---------------------+------------------+
+---+--------------+---------------------+------------------+
| | idProduction | dateProduction | statusProduction |
+---+--------------+---------------------+------------------+
| 1 | 1 | 20.11.2018 00:00:00 | done |
+---+--------------+---------------------+------------------+
add a comment |
up vote
0
down vote
up vote
0
down vote
I am unable to reproduce your problem, see https://rextester.com/OQI5184
#MySQL 5.7.12
#'\' is a delimiter
DROP TABLE IF EXISTS tblProduction;
CREATE TABLE IF NOT EXISTS tblProduction (
idProduction INT NOT NULL AUTO_INCREMENT
, dateProduction DATETIME NOT NULL
, statusProduction VARCHAR(15) NOT NULL
, PRIMARY KEY (idProduction)
)
;
INSERT INTO tblProduction(dateProduction,statusProduction) VALUES ('2018-11-20','start');
SELECT * FROM tblProduction;
UPDATE tblproduction
SET statusProduction = 'done'
WHERE idProduction=1;
SELECT * FROM tblProduction;
RESULTS:
+---+--------------+---------------------+------------------+
| | idProduction | dateProduction | statusProduction |
+---+--------------+---------------------+------------------+
| 1 | 1 | 20.11.2018 00:00:00 | start |
+---+--------------+---------------------+------------------+
+---+--------------+---------------------+------------------+
| | idProduction | dateProduction | statusProduction |
+---+--------------+---------------------+------------------+
| 1 | 1 | 20.11.2018 00:00:00 | done |
+---+--------------+---------------------+------------------+
I am unable to reproduce your problem, see https://rextester.com/OQI5184
#MySQL 5.7.12
#'\' is a delimiter
DROP TABLE IF EXISTS tblProduction;
CREATE TABLE IF NOT EXISTS tblProduction (
idProduction INT NOT NULL AUTO_INCREMENT
, dateProduction DATETIME NOT NULL
, statusProduction VARCHAR(15) NOT NULL
, PRIMARY KEY (idProduction)
)
;
INSERT INTO tblProduction(dateProduction,statusProduction) VALUES ('2018-11-20','start');
SELECT * FROM tblProduction;
UPDATE tblproduction
SET statusProduction = 'done'
WHERE idProduction=1;
SELECT * FROM tblProduction;
RESULTS:
+---+--------------+---------------------+------------------+
| | idProduction | dateProduction | statusProduction |
+---+--------------+---------------------+------------------+
| 1 | 1 | 20.11.2018 00:00:00 | start |
+---+--------------+---------------------+------------------+
+---+--------------+---------------------+------------------+
| | idProduction | dateProduction | statusProduction |
+---+--------------+---------------------+------------------+
| 1 | 1 | 20.11.2018 00:00:00 | done |
+---+--------------+---------------------+------------------+
answered Nov 20 at 0:19
Used_By_Already
21.9k21838
21.9k21838
add a comment |
add a comment |
up vote
0
down vote
So the problem wasn't neither the query nor the table, there was an update trigger on this table (witch I dropped for testing and didn't work), to sum up I had to drop the database and created it all once again without creating the trigger. This time the update query worked, I'm working on the trigger now to see if I can find what's wrong
add a comment |
up vote
0
down vote
So the problem wasn't neither the query nor the table, there was an update trigger on this table (witch I dropped for testing and didn't work), to sum up I had to drop the database and created it all once again without creating the trigger. This time the update query worked, I'm working on the trigger now to see if I can find what's wrong
add a comment |
up vote
0
down vote
up vote
0
down vote
So the problem wasn't neither the query nor the table, there was an update trigger on this table (witch I dropped for testing and didn't work), to sum up I had to drop the database and created it all once again without creating the trigger. This time the update query worked, I'm working on the trigger now to see if I can find what's wrong
So the problem wasn't neither the query nor the table, there was an update trigger on this table (witch I dropped for testing and didn't work), to sum up I had to drop the database and created it all once again without creating the trigger. This time the update query worked, I'm working on the trigger now to see if I can find what's wrong
answered Nov 20 at 0:38
Fabricio Montagnani
12
12
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53366418%2fwhy-do-mysql-return-error-code-1241-on-update-query%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
can you please provide the complete DDL for creating this table.
– Used_By_Already
Nov 19 at 3:09
The error message does not fit your query, but I would check if you have an update trigger on your table, it might contain incorrect code (that will only run when your where-condition leads to an actual update, so probably not for
id='a').– Solarflare
Nov 19 at 3:40
@Used_By_Already DDL statement as down below: CREATE TABLE IF NOT EXISTS
milani.tblProduction(idProductionINT NOT NULL AUTO_INCREMENT,dateProductionDATETIME NOT NULL,statusProductionVARCHAR(15) NOT NULL, PRIMARY KEY (idProduction))– Fabricio Montagnani
Nov 19 at 23:56
These small comments are not the place to add code. We expect important information like that DDL to be added into the question (there is an edit link for that reason) and in the question it can be properly formatted.
– Used_By_Already
Nov 20 at 0:09
@Solarflare there is a UPDATE trigger indeed, that I've dropped for testing and got the same outcome... I dropped the entire database and created it again without creating the update trigger this time and the update statement did work this time, thank you! I'm going to work on the trigger now
– Fabricio Montagnani
Nov 20 at 0:23