MySQL - Stored Procedure error Operand should contain 1 columnSelect columns from result set of stored procedureWhich MySQL data type to use for storing boolean valuesShould I use the datetime or timestamp data type in MySQL?Insert results of a stored procedure into a temporary tableList of Stored Procedures/Functions Mysql Command LineMysql Call Stored procedure from another stored procedureFunction vs. Stored Procedure in SQL ServerScope of temp tables created in MySQL stored procedureHow to get results of stored procedure #1 into a temporary table in stored procedure #2Search text in stored procedure in SQL Server
Given 0s on Assignments with suspected and dismissed cheating?
When the match time is called, does the current turn end immediately?
SHAKE-128/256 or SHA3-256/512
Why do academics prefer Mac/Linux?
Would life always name the light from their sun "white"
"Counterexample" for the Inverse function theorem
Find the area of the rectangle
Polynomial division: Is this trick obvious?
Would it be fair to use 1d30 (instead of rolling 2d20 and taking the higher die) for advantage rolls?
AD: OU for system administrator accounts
What is this rubber on gear cables
I recently started my machine learning PhD and I have absolutely no idea what I'm doing
Why is it correct to use ~た in this sentence, even though we're talking about next week?
Why is the marginal distribution/marginal probability described as "marginal"?
Is there an academic word that means "to split hairs over"?
Why do galaxies collide?
Is Big Ben visible from the British museum?
How do Ctrl+C and Ctrl+V work?
Promotion comes with unexpected 24/7/365 on-call
A person lacking money who shows off a lot
Why can't I share a one use code with anyone else?
How come Arya Stark didn't burn in Game of Thrones Season 8 Episode 5
How does the Heat Metal spell interact with a follow-up Frostbite spell?
Have there been any examples of re-usable rockets in the past?
MySQL - Stored Procedure error Operand should contain 1 column
Select columns from result set of stored procedureWhich MySQL data type to use for storing boolean valuesShould I use the datetime or timestamp data type in MySQL?Insert results of a stored procedure into a temporary tableList of Stored Procedures/Functions Mysql Command LineMysql Call Stored procedure from another stored procedureFunction vs. Stored Procedure in SQL ServerScope of temp tables created in MySQL stored procedureHow to get results of stored procedure #1 into a temporary table in stored procedure #2Search text in stored procedure in SQL Server
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have this stored procedure in MySQL database, but when I test it like below, I get Operand should contain 1 column(s)
error:
CALL `get_strongest_policy_from_all_involved_accounts_for_user`(57);
And this is my stored procedure. The code from line 6 to 20 works fine and it returns a table of 0 or more records.
Can somebody please help me fix the erroras I don't know what causes it. Many thanks!
CREATE DEFINER=`root`@`localhost` PROCEDURE `get_strongest_policy_from_all_involved_accounts_for_user` (
IN app_user_id INT
)
BEGIN
CREATE TEMPORARY TABLE `ParentAccountPolicies` ENGINE=MEMORY SELECT (
SELECT UAS.`password_rotation_active`, UAS.`password_rotation_days`, UAS.`Password_minimum_lenght`,
UAS.`password_must_contain_numeric_char`, UAS.`password_must_contain_lowercase_char`,
UAS.`password_must_contain_upercase_char`, UAS.`password_must_contain_special_char`
FROM `user_account` UA, `user_account_settings` UAS
WHERE UA.`account_id` = UAS.`account_id`
AND UA.`primary_user_id` = app_user_id
UNION
SELECT UAS.`password_rotation_active`, UAS.`password_rotation_days`, UAS.`Password_minimum_lenght`,
UAS.`password_must_contain_numeric_char`, UAS.`password_must_contain_lowercase_char`,
UAS.`password_must_contain_upercase_char`, UAS.`password_must_contain_special_char`
FROM `user_account` UA, `business` B, `app_user_n_business` AUB, `user_account_settings` UAS
WHERE UA.`business_id` = B.`business_id`
AND B.`business_id` = AUB.`business_id`
AND UAS.`account_id` = UA.`account_id`
AND AUB.`app_user_id` = app_user_id
);
SET @RotationActive = B'0', @HaveNum = B'0', @HaveLowCase = B'0', @HaveUpCase = B'0', @HaveSpecial = B'0';
SET @RotationDays = 0, @MinLength = 0;
IF (SELECT DISTINCT `password_rotation_active` FROM `ParentAccountPolicies` WHERE `password_rotation_active` = TRUE) IS NOT NULL THEN
SET @RotationActive = B'1';
END IF;
IF (SELECT DISTINCT `password_must_contain_numeric_char` FROM `ParentAccountPolicies` WHERE `password_must_contain_numeric_char` = TRUE) IS NOT NULL THEN
SET @HaveNum = B'1';
END IF;
IF (SELECT DISTINCT `password_must_contain_lowercase_char` FROM `ParentAccountPolicies` WHERE `password_must_contain_lowercase_char` = TRUE) IS NOT NULL THEN
SET @HaveLowCase = B'1';
END IF;
IF (SELECT DISTINCT `password_must_contain_upercase_char` FROM `ParentAccountPolicies` WHERE `password_must_contain_upercase_char` = TRUE) IS NOT NULL THEN
SET @HaveUpCase = B'1';
END IF;
IF (SELECT DISTINCT `password_must_contain_special_char` FROM `ParentAccountPolicies` WHERE `password_must_contain_special_char` = TRUE) IS NOT NULL THEN
SET @HaveSpecial = B'1';
END IF;
SELECT MAX(`password_rotation_days`) INTO @RotationDays FROM `ParentAccountPolicies`;
SELECT MAX(`Password_minimum_lenght`) INTO @RotationDays FROM `ParentAccountPolicies`;
CREATE TEMPORARY TABLE `FinalPolicy` (
`RotationActive` BIT,
`RotationDays` INT,
`MinimumLength` INT,
`ShouldHaveDigit` BIT,
`ShouldHaveLowerCaseChar` BIT,
`ShouldHaveUpperCaseChar` BIT,
`ShouldHaveSpecialChar` BIT
);
INSERT INTO `FinalPolicy` VALUES (@RotationActive, @RotationDays, @MinLength, @HaveNum, @HaveLowCase, @HaveUpCase, @HaveSpecial);
SELECT `FinalPolicy`;
END;
mysql stored-procedures temp-tables
add a comment |
I have this stored procedure in MySQL database, but when I test it like below, I get Operand should contain 1 column(s)
error:
CALL `get_strongest_policy_from_all_involved_accounts_for_user`(57);
And this is my stored procedure. The code from line 6 to 20 works fine and it returns a table of 0 or more records.
Can somebody please help me fix the erroras I don't know what causes it. Many thanks!
CREATE DEFINER=`root`@`localhost` PROCEDURE `get_strongest_policy_from_all_involved_accounts_for_user` (
IN app_user_id INT
)
BEGIN
CREATE TEMPORARY TABLE `ParentAccountPolicies` ENGINE=MEMORY SELECT (
SELECT UAS.`password_rotation_active`, UAS.`password_rotation_days`, UAS.`Password_minimum_lenght`,
UAS.`password_must_contain_numeric_char`, UAS.`password_must_contain_lowercase_char`,
UAS.`password_must_contain_upercase_char`, UAS.`password_must_contain_special_char`
FROM `user_account` UA, `user_account_settings` UAS
WHERE UA.`account_id` = UAS.`account_id`
AND UA.`primary_user_id` = app_user_id
UNION
SELECT UAS.`password_rotation_active`, UAS.`password_rotation_days`, UAS.`Password_minimum_lenght`,
UAS.`password_must_contain_numeric_char`, UAS.`password_must_contain_lowercase_char`,
UAS.`password_must_contain_upercase_char`, UAS.`password_must_contain_special_char`
FROM `user_account` UA, `business` B, `app_user_n_business` AUB, `user_account_settings` UAS
WHERE UA.`business_id` = B.`business_id`
AND B.`business_id` = AUB.`business_id`
AND UAS.`account_id` = UA.`account_id`
AND AUB.`app_user_id` = app_user_id
);
SET @RotationActive = B'0', @HaveNum = B'0', @HaveLowCase = B'0', @HaveUpCase = B'0', @HaveSpecial = B'0';
SET @RotationDays = 0, @MinLength = 0;
IF (SELECT DISTINCT `password_rotation_active` FROM `ParentAccountPolicies` WHERE `password_rotation_active` = TRUE) IS NOT NULL THEN
SET @RotationActive = B'1';
END IF;
IF (SELECT DISTINCT `password_must_contain_numeric_char` FROM `ParentAccountPolicies` WHERE `password_must_contain_numeric_char` = TRUE) IS NOT NULL THEN
SET @HaveNum = B'1';
END IF;
IF (SELECT DISTINCT `password_must_contain_lowercase_char` FROM `ParentAccountPolicies` WHERE `password_must_contain_lowercase_char` = TRUE) IS NOT NULL THEN
SET @HaveLowCase = B'1';
END IF;
IF (SELECT DISTINCT `password_must_contain_upercase_char` FROM `ParentAccountPolicies` WHERE `password_must_contain_upercase_char` = TRUE) IS NOT NULL THEN
SET @HaveUpCase = B'1';
END IF;
IF (SELECT DISTINCT `password_must_contain_special_char` FROM `ParentAccountPolicies` WHERE `password_must_contain_special_char` = TRUE) IS NOT NULL THEN
SET @HaveSpecial = B'1';
END IF;
SELECT MAX(`password_rotation_days`) INTO @RotationDays FROM `ParentAccountPolicies`;
SELECT MAX(`Password_minimum_lenght`) INTO @RotationDays FROM `ParentAccountPolicies`;
CREATE TEMPORARY TABLE `FinalPolicy` (
`RotationActive` BIT,
`RotationDays` INT,
`MinimumLength` INT,
`ShouldHaveDigit` BIT,
`ShouldHaveLowerCaseChar` BIT,
`ShouldHaveUpperCaseChar` BIT,
`ShouldHaveSpecialChar` BIT
);
INSERT INTO `FinalPolicy` VALUES (@RotationActive, @RotationDays, @MinLength, @HaveNum, @HaveLowCase, @HaveUpCase, @HaveSpecial);
SELECT `FinalPolicy`;
END;
mysql stored-procedures temp-tables
Remove the very firstSELECT
– Paul Spiegel
Mar 23 at 16:22
Removing it causes syntax error in the create command
– LK Phuc Nguyen
Mar 23 at 16:30
Use create temporary table_name as select
– Kedar Limaye
Mar 23 at 16:34
I still get the same error. Sorry.
– LK Phuc Nguyen
Mar 23 at 16:37
add a comment |
I have this stored procedure in MySQL database, but when I test it like below, I get Operand should contain 1 column(s)
error:
CALL `get_strongest_policy_from_all_involved_accounts_for_user`(57);
And this is my stored procedure. The code from line 6 to 20 works fine and it returns a table of 0 or more records.
Can somebody please help me fix the erroras I don't know what causes it. Many thanks!
CREATE DEFINER=`root`@`localhost` PROCEDURE `get_strongest_policy_from_all_involved_accounts_for_user` (
IN app_user_id INT
)
BEGIN
CREATE TEMPORARY TABLE `ParentAccountPolicies` ENGINE=MEMORY SELECT (
SELECT UAS.`password_rotation_active`, UAS.`password_rotation_days`, UAS.`Password_minimum_lenght`,
UAS.`password_must_contain_numeric_char`, UAS.`password_must_contain_lowercase_char`,
UAS.`password_must_contain_upercase_char`, UAS.`password_must_contain_special_char`
FROM `user_account` UA, `user_account_settings` UAS
WHERE UA.`account_id` = UAS.`account_id`
AND UA.`primary_user_id` = app_user_id
UNION
SELECT UAS.`password_rotation_active`, UAS.`password_rotation_days`, UAS.`Password_minimum_lenght`,
UAS.`password_must_contain_numeric_char`, UAS.`password_must_contain_lowercase_char`,
UAS.`password_must_contain_upercase_char`, UAS.`password_must_contain_special_char`
FROM `user_account` UA, `business` B, `app_user_n_business` AUB, `user_account_settings` UAS
WHERE UA.`business_id` = B.`business_id`
AND B.`business_id` = AUB.`business_id`
AND UAS.`account_id` = UA.`account_id`
AND AUB.`app_user_id` = app_user_id
);
SET @RotationActive = B'0', @HaveNum = B'0', @HaveLowCase = B'0', @HaveUpCase = B'0', @HaveSpecial = B'0';
SET @RotationDays = 0, @MinLength = 0;
IF (SELECT DISTINCT `password_rotation_active` FROM `ParentAccountPolicies` WHERE `password_rotation_active` = TRUE) IS NOT NULL THEN
SET @RotationActive = B'1';
END IF;
IF (SELECT DISTINCT `password_must_contain_numeric_char` FROM `ParentAccountPolicies` WHERE `password_must_contain_numeric_char` = TRUE) IS NOT NULL THEN
SET @HaveNum = B'1';
END IF;
IF (SELECT DISTINCT `password_must_contain_lowercase_char` FROM `ParentAccountPolicies` WHERE `password_must_contain_lowercase_char` = TRUE) IS NOT NULL THEN
SET @HaveLowCase = B'1';
END IF;
IF (SELECT DISTINCT `password_must_contain_upercase_char` FROM `ParentAccountPolicies` WHERE `password_must_contain_upercase_char` = TRUE) IS NOT NULL THEN
SET @HaveUpCase = B'1';
END IF;
IF (SELECT DISTINCT `password_must_contain_special_char` FROM `ParentAccountPolicies` WHERE `password_must_contain_special_char` = TRUE) IS NOT NULL THEN
SET @HaveSpecial = B'1';
END IF;
SELECT MAX(`password_rotation_days`) INTO @RotationDays FROM `ParentAccountPolicies`;
SELECT MAX(`Password_minimum_lenght`) INTO @RotationDays FROM `ParentAccountPolicies`;
CREATE TEMPORARY TABLE `FinalPolicy` (
`RotationActive` BIT,
`RotationDays` INT,
`MinimumLength` INT,
`ShouldHaveDigit` BIT,
`ShouldHaveLowerCaseChar` BIT,
`ShouldHaveUpperCaseChar` BIT,
`ShouldHaveSpecialChar` BIT
);
INSERT INTO `FinalPolicy` VALUES (@RotationActive, @RotationDays, @MinLength, @HaveNum, @HaveLowCase, @HaveUpCase, @HaveSpecial);
SELECT `FinalPolicy`;
END;
mysql stored-procedures temp-tables
I have this stored procedure in MySQL database, but when I test it like below, I get Operand should contain 1 column(s)
error:
CALL `get_strongest_policy_from_all_involved_accounts_for_user`(57);
And this is my stored procedure. The code from line 6 to 20 works fine and it returns a table of 0 or more records.
Can somebody please help me fix the erroras I don't know what causes it. Many thanks!
CREATE DEFINER=`root`@`localhost` PROCEDURE `get_strongest_policy_from_all_involved_accounts_for_user` (
IN app_user_id INT
)
BEGIN
CREATE TEMPORARY TABLE `ParentAccountPolicies` ENGINE=MEMORY SELECT (
SELECT UAS.`password_rotation_active`, UAS.`password_rotation_days`, UAS.`Password_minimum_lenght`,
UAS.`password_must_contain_numeric_char`, UAS.`password_must_contain_lowercase_char`,
UAS.`password_must_contain_upercase_char`, UAS.`password_must_contain_special_char`
FROM `user_account` UA, `user_account_settings` UAS
WHERE UA.`account_id` = UAS.`account_id`
AND UA.`primary_user_id` = app_user_id
UNION
SELECT UAS.`password_rotation_active`, UAS.`password_rotation_days`, UAS.`Password_minimum_lenght`,
UAS.`password_must_contain_numeric_char`, UAS.`password_must_contain_lowercase_char`,
UAS.`password_must_contain_upercase_char`, UAS.`password_must_contain_special_char`
FROM `user_account` UA, `business` B, `app_user_n_business` AUB, `user_account_settings` UAS
WHERE UA.`business_id` = B.`business_id`
AND B.`business_id` = AUB.`business_id`
AND UAS.`account_id` = UA.`account_id`
AND AUB.`app_user_id` = app_user_id
);
SET @RotationActive = B'0', @HaveNum = B'0', @HaveLowCase = B'0', @HaveUpCase = B'0', @HaveSpecial = B'0';
SET @RotationDays = 0, @MinLength = 0;
IF (SELECT DISTINCT `password_rotation_active` FROM `ParentAccountPolicies` WHERE `password_rotation_active` = TRUE) IS NOT NULL THEN
SET @RotationActive = B'1';
END IF;
IF (SELECT DISTINCT `password_must_contain_numeric_char` FROM `ParentAccountPolicies` WHERE `password_must_contain_numeric_char` = TRUE) IS NOT NULL THEN
SET @HaveNum = B'1';
END IF;
IF (SELECT DISTINCT `password_must_contain_lowercase_char` FROM `ParentAccountPolicies` WHERE `password_must_contain_lowercase_char` = TRUE) IS NOT NULL THEN
SET @HaveLowCase = B'1';
END IF;
IF (SELECT DISTINCT `password_must_contain_upercase_char` FROM `ParentAccountPolicies` WHERE `password_must_contain_upercase_char` = TRUE) IS NOT NULL THEN
SET @HaveUpCase = B'1';
END IF;
IF (SELECT DISTINCT `password_must_contain_special_char` FROM `ParentAccountPolicies` WHERE `password_must_contain_special_char` = TRUE) IS NOT NULL THEN
SET @HaveSpecial = B'1';
END IF;
SELECT MAX(`password_rotation_days`) INTO @RotationDays FROM `ParentAccountPolicies`;
SELECT MAX(`Password_minimum_lenght`) INTO @RotationDays FROM `ParentAccountPolicies`;
CREATE TEMPORARY TABLE `FinalPolicy` (
`RotationActive` BIT,
`RotationDays` INT,
`MinimumLength` INT,
`ShouldHaveDigit` BIT,
`ShouldHaveLowerCaseChar` BIT,
`ShouldHaveUpperCaseChar` BIT,
`ShouldHaveSpecialChar` BIT
);
INSERT INTO `FinalPolicy` VALUES (@RotationActive, @RotationDays, @MinLength, @HaveNum, @HaveLowCase, @HaveUpCase, @HaveSpecial);
SELECT `FinalPolicy`;
END;
mysql stored-procedures temp-tables
mysql stored-procedures temp-tables
asked Mar 23 at 16:13
LK Phuc NguyenLK Phuc Nguyen
158110
158110
Remove the very firstSELECT
– Paul Spiegel
Mar 23 at 16:22
Removing it causes syntax error in the create command
– LK Phuc Nguyen
Mar 23 at 16:30
Use create temporary table_name as select
– Kedar Limaye
Mar 23 at 16:34
I still get the same error. Sorry.
– LK Phuc Nguyen
Mar 23 at 16:37
add a comment |
Remove the very firstSELECT
– Paul Spiegel
Mar 23 at 16:22
Removing it causes syntax error in the create command
– LK Phuc Nguyen
Mar 23 at 16:30
Use create temporary table_name as select
– Kedar Limaye
Mar 23 at 16:34
I still get the same error. Sorry.
– LK Phuc Nguyen
Mar 23 at 16:37
Remove the very first
SELECT
– Paul Spiegel
Mar 23 at 16:22
Remove the very first
SELECT
– Paul Spiegel
Mar 23 at 16:22
Removing it causes syntax error in the create command
– LK Phuc Nguyen
Mar 23 at 16:30
Removing it causes syntax error in the create command
– LK Phuc Nguyen
Mar 23 at 16:30
Use create temporary table_name as select
– Kedar Limaye
Mar 23 at 16:34
Use create temporary table_name as select
– Kedar Limaye
Mar 23 at 16:34
I still get the same error. Sorry.
– LK Phuc Nguyen
Mar 23 at 16:37
I still get the same error. Sorry.
– LK Phuc Nguyen
Mar 23 at 16:37
add a comment |
1 Answer
1
active
oldest
votes
You do something like this:
CREATE TEMPORARY TABLE `ParentAccountPolicies` ENGINE=MEMORY SELECT (
SELECT 'a' as x, 'b' as y
FROM dual
UNION
SELECT 'c' as x, 'd' as y
FROM dual
);
This results in the following error:
ER_OPERAND_COLUMNS: Operand should contain 1 column(s)
Demo
The reason is that you have a subselect (subquery in SELECT clause) which must return exactly one column and at most one row. But your subselect returns multiple columns.
But you don't need to use a subselect at all. Just remove the outer SELECT like here:
CREATE TEMPORARY TABLE `ParentAccountPolicies` ENGINE=MEMORY
SELECT 'a' as x, 'b' as y
FROM dual
UNION
SELECT 'c' as x, 'd' as y
FROM dual
;
Demo
Thank you so much. Now I get what went wrong in the command.
– LK Phuc Nguyen
Mar 23 at 16:44
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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%2f55315754%2fmysql-stored-procedure-error-operand-should-contain-1-column%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You do something like this:
CREATE TEMPORARY TABLE `ParentAccountPolicies` ENGINE=MEMORY SELECT (
SELECT 'a' as x, 'b' as y
FROM dual
UNION
SELECT 'c' as x, 'd' as y
FROM dual
);
This results in the following error:
ER_OPERAND_COLUMNS: Operand should contain 1 column(s)
Demo
The reason is that you have a subselect (subquery in SELECT clause) which must return exactly one column and at most one row. But your subselect returns multiple columns.
But you don't need to use a subselect at all. Just remove the outer SELECT like here:
CREATE TEMPORARY TABLE `ParentAccountPolicies` ENGINE=MEMORY
SELECT 'a' as x, 'b' as y
FROM dual
UNION
SELECT 'c' as x, 'd' as y
FROM dual
;
Demo
Thank you so much. Now I get what went wrong in the command.
– LK Phuc Nguyen
Mar 23 at 16:44
add a comment |
You do something like this:
CREATE TEMPORARY TABLE `ParentAccountPolicies` ENGINE=MEMORY SELECT (
SELECT 'a' as x, 'b' as y
FROM dual
UNION
SELECT 'c' as x, 'd' as y
FROM dual
);
This results in the following error:
ER_OPERAND_COLUMNS: Operand should contain 1 column(s)
Demo
The reason is that you have a subselect (subquery in SELECT clause) which must return exactly one column and at most one row. But your subselect returns multiple columns.
But you don't need to use a subselect at all. Just remove the outer SELECT like here:
CREATE TEMPORARY TABLE `ParentAccountPolicies` ENGINE=MEMORY
SELECT 'a' as x, 'b' as y
FROM dual
UNION
SELECT 'c' as x, 'd' as y
FROM dual
;
Demo
Thank you so much. Now I get what went wrong in the command.
– LK Phuc Nguyen
Mar 23 at 16:44
add a comment |
You do something like this:
CREATE TEMPORARY TABLE `ParentAccountPolicies` ENGINE=MEMORY SELECT (
SELECT 'a' as x, 'b' as y
FROM dual
UNION
SELECT 'c' as x, 'd' as y
FROM dual
);
This results in the following error:
ER_OPERAND_COLUMNS: Operand should contain 1 column(s)
Demo
The reason is that you have a subselect (subquery in SELECT clause) which must return exactly one column and at most one row. But your subselect returns multiple columns.
But you don't need to use a subselect at all. Just remove the outer SELECT like here:
CREATE TEMPORARY TABLE `ParentAccountPolicies` ENGINE=MEMORY
SELECT 'a' as x, 'b' as y
FROM dual
UNION
SELECT 'c' as x, 'd' as y
FROM dual
;
Demo
You do something like this:
CREATE TEMPORARY TABLE `ParentAccountPolicies` ENGINE=MEMORY SELECT (
SELECT 'a' as x, 'b' as y
FROM dual
UNION
SELECT 'c' as x, 'd' as y
FROM dual
);
This results in the following error:
ER_OPERAND_COLUMNS: Operand should contain 1 column(s)
Demo
The reason is that you have a subselect (subquery in SELECT clause) which must return exactly one column and at most one row. But your subselect returns multiple columns.
But you don't need to use a subselect at all. Just remove the outer SELECT like here:
CREATE TEMPORARY TABLE `ParentAccountPolicies` ENGINE=MEMORY
SELECT 'a' as x, 'b' as y
FROM dual
UNION
SELECT 'c' as x, 'd' as y
FROM dual
;
Demo
answered Mar 23 at 16:39
Paul SpiegelPaul Spiegel
18.8k32737
18.8k32737
Thank you so much. Now I get what went wrong in the command.
– LK Phuc Nguyen
Mar 23 at 16:44
add a comment |
Thank you so much. Now I get what went wrong in the command.
– LK Phuc Nguyen
Mar 23 at 16:44
Thank you so much. Now I get what went wrong in the command.
– LK Phuc Nguyen
Mar 23 at 16:44
Thank you so much. Now I get what went wrong in the command.
– LK Phuc Nguyen
Mar 23 at 16:44
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.
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%2f55315754%2fmysql-stored-procedure-error-operand-should-contain-1-column%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
Remove the very first
SELECT
– Paul Spiegel
Mar 23 at 16:22
Removing it causes syntax error in the create command
– LK Phuc Nguyen
Mar 23 at 16:30
Use create temporary table_name as select
– Kedar Limaye
Mar 23 at 16:34
I still get the same error. Sorry.
– LK Phuc Nguyen
Mar 23 at 16:37