Making a union of views in MySQL Stored Procedure
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I'm creating a MySQL stored procedure that receives the names of two views, and performs a Union upon them into the first of the two.
I've used prepared statements to take view names as strings, so I can use this stored procedure with a wealth of other stored procedures that produce views of varying names.
The following code works as expected:
DROP view if exists test1;
DROP view if exists test2;
CREATE VIEW test1 as SELECT "Cows";
CREATE VIEW test2 as SELECT "Horses";
DROP VIEW if exists tempView;
CREATE VIEW tempView AS SELECT * FROM test1 UNION SELECT * FROM test2;
SELECT * from tempView;
However, when I execute the following code:
DELIMITER //
DROP PROCEDURE IF EXISTS SP_unionViews //
CREATE PROCEDURE SP_unionViews(IN viewname varchar(255),
IN viewname2 varchar(255))
BEGIN
DROP VIEW IF EXISTS tempView;
SET @in1 = viewname;
SET @in2 = viewname2;
SET @str = 'CREATE VIEW tempView AS
SELECT * FROM ? UNION SELECT * FROM ?';
PREPARE stmt FROM @str;
EXECUTE stmt USING @in1, @in2;
SET @str2 = 'DROP VIEW ?';
SET @in3 = viewname;
PREPARE stmt2 FROM @str2;
EXECUTE stmt2 USING @in3;
SET @str3 = 'CREATE VIEW ? AS SELECT * FROM tempView';
PREPARE stmt3 FROM @str3;
EXECUTE stmt3 USING @in3;
DEALLOCATE PREPARE stmt;
DEALLOCATE PREPARE stmt2;
DEALLOCATE PREPARE stmt3;
END //
DELIMITER ;
DROP view if exists test1;
DROP view if exists test2;
CREATE VIEW test1 as SELECT "Cows";
CREATE VIEW test2 as SELECT "Horses";
CALL SP_unionViews(test1, test2);
SELECT * from test1;
I get the following error:
#1054 - Unknown column 'test1' in 'field list'
That would seem to indicate that this stored procedure is trying to use test1 as a column somewhere it's not intended to be one. But I can't figure out where.
UPDATE:
When edited as below, I expected the solution to work, but it gives me another error.
The new code reads:
DELIMITER //
DROP PROCEDURE IF EXISTS SP_unionViews //
CREATE PROCEDURE SP_unionViews(IN viewname varchar(255),
IN viewname2 varchar(255))
BEGIN
DROP VIEW IF EXISTS tempView;
SET @str = CONCAT('
CREATE VIEW tempView AS
SELECT * FROM ', viewname, ' UNION SELECT * FROM ', viewname2);
PREPARE stmt FROM @str;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET @str2 = CONCAT('DROP VIEW ', viewname, ';');
PREPARE stmt2 FROM @str2;
EXECUTE stmt2;
DEALLOCATE PREPARE stmt2;
SET @str3 = CONCAT('CREATE VIEW ', viewname ,' AS SELECT * FROM tempView');
PREPARE stmt3 FROM @str3;
EXECUTE stmt3;
DEALLOCATE PREPARE stmt3;
END //
DELIMITER ;
DROP view if exists test1;
DROP view if exists test2;
CREATE VIEW test1 as SELECT "Cows";
CREATE VIEW test2 as SELECT "Horses";
CALL SP_unionViews("test1", "test2");
SELECT * from test1;
And its error reads:
#1615 - Prepared statement needs to be re-prepared
mysql stored-procedures prepared-statement union sql-view
add a comment |
I'm creating a MySQL stored procedure that receives the names of two views, and performs a Union upon them into the first of the two.
I've used prepared statements to take view names as strings, so I can use this stored procedure with a wealth of other stored procedures that produce views of varying names.
The following code works as expected:
DROP view if exists test1;
DROP view if exists test2;
CREATE VIEW test1 as SELECT "Cows";
CREATE VIEW test2 as SELECT "Horses";
DROP VIEW if exists tempView;
CREATE VIEW tempView AS SELECT * FROM test1 UNION SELECT * FROM test2;
SELECT * from tempView;
However, when I execute the following code:
DELIMITER //
DROP PROCEDURE IF EXISTS SP_unionViews //
CREATE PROCEDURE SP_unionViews(IN viewname varchar(255),
IN viewname2 varchar(255))
BEGIN
DROP VIEW IF EXISTS tempView;
SET @in1 = viewname;
SET @in2 = viewname2;
SET @str = 'CREATE VIEW tempView AS
SELECT * FROM ? UNION SELECT * FROM ?';
PREPARE stmt FROM @str;
EXECUTE stmt USING @in1, @in2;
SET @str2 = 'DROP VIEW ?';
SET @in3 = viewname;
PREPARE stmt2 FROM @str2;
EXECUTE stmt2 USING @in3;
SET @str3 = 'CREATE VIEW ? AS SELECT * FROM tempView';
PREPARE stmt3 FROM @str3;
EXECUTE stmt3 USING @in3;
DEALLOCATE PREPARE stmt;
DEALLOCATE PREPARE stmt2;
DEALLOCATE PREPARE stmt3;
END //
DELIMITER ;
DROP view if exists test1;
DROP view if exists test2;
CREATE VIEW test1 as SELECT "Cows";
CREATE VIEW test2 as SELECT "Horses";
CALL SP_unionViews(test1, test2);
SELECT * from test1;
I get the following error:
#1054 - Unknown column 'test1' in 'field list'
That would seem to indicate that this stored procedure is trying to use test1 as a column somewhere it's not intended to be one. But I can't figure out where.
UPDATE:
When edited as below, I expected the solution to work, but it gives me another error.
The new code reads:
DELIMITER //
DROP PROCEDURE IF EXISTS SP_unionViews //
CREATE PROCEDURE SP_unionViews(IN viewname varchar(255),
IN viewname2 varchar(255))
BEGIN
DROP VIEW IF EXISTS tempView;
SET @str = CONCAT('
CREATE VIEW tempView AS
SELECT * FROM ', viewname, ' UNION SELECT * FROM ', viewname2);
PREPARE stmt FROM @str;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET @str2 = CONCAT('DROP VIEW ', viewname, ';');
PREPARE stmt2 FROM @str2;
EXECUTE stmt2;
DEALLOCATE PREPARE stmt2;
SET @str3 = CONCAT('CREATE VIEW ', viewname ,' AS SELECT * FROM tempView');
PREPARE stmt3 FROM @str3;
EXECUTE stmt3;
DEALLOCATE PREPARE stmt3;
END //
DELIMITER ;
DROP view if exists test1;
DROP view if exists test2;
CREATE VIEW test1 as SELECT "Cows";
CREATE VIEW test2 as SELECT "Horses";
CALL SP_unionViews("test1", "test2");
SELECT * from test1;
And its error reads:
#1615 - Prepared statement needs to be re-prepared
mysql stored-procedures prepared-statement union sql-view
btw, please don't worry about the 'Select *' stuff. This is boilerplate.
– Feygon
Nov 17 '18 at 7:28
Edited to fix: "test1", "test2" needed to be string literals.
– Feygon
Nov 17 '18 at 8:14
Also edited to fix: Creating a view didn't like the subquery.
– Feygon
Nov 17 '18 at 8:14
add a comment |
I'm creating a MySQL stored procedure that receives the names of two views, and performs a Union upon them into the first of the two.
I've used prepared statements to take view names as strings, so I can use this stored procedure with a wealth of other stored procedures that produce views of varying names.
The following code works as expected:
DROP view if exists test1;
DROP view if exists test2;
CREATE VIEW test1 as SELECT "Cows";
CREATE VIEW test2 as SELECT "Horses";
DROP VIEW if exists tempView;
CREATE VIEW tempView AS SELECT * FROM test1 UNION SELECT * FROM test2;
SELECT * from tempView;
However, when I execute the following code:
DELIMITER //
DROP PROCEDURE IF EXISTS SP_unionViews //
CREATE PROCEDURE SP_unionViews(IN viewname varchar(255),
IN viewname2 varchar(255))
BEGIN
DROP VIEW IF EXISTS tempView;
SET @in1 = viewname;
SET @in2 = viewname2;
SET @str = 'CREATE VIEW tempView AS
SELECT * FROM ? UNION SELECT * FROM ?';
PREPARE stmt FROM @str;
EXECUTE stmt USING @in1, @in2;
SET @str2 = 'DROP VIEW ?';
SET @in3 = viewname;
PREPARE stmt2 FROM @str2;
EXECUTE stmt2 USING @in3;
SET @str3 = 'CREATE VIEW ? AS SELECT * FROM tempView';
PREPARE stmt3 FROM @str3;
EXECUTE stmt3 USING @in3;
DEALLOCATE PREPARE stmt;
DEALLOCATE PREPARE stmt2;
DEALLOCATE PREPARE stmt3;
END //
DELIMITER ;
DROP view if exists test1;
DROP view if exists test2;
CREATE VIEW test1 as SELECT "Cows";
CREATE VIEW test2 as SELECT "Horses";
CALL SP_unionViews(test1, test2);
SELECT * from test1;
I get the following error:
#1054 - Unknown column 'test1' in 'field list'
That would seem to indicate that this stored procedure is trying to use test1 as a column somewhere it's not intended to be one. But I can't figure out where.
UPDATE:
When edited as below, I expected the solution to work, but it gives me another error.
The new code reads:
DELIMITER //
DROP PROCEDURE IF EXISTS SP_unionViews //
CREATE PROCEDURE SP_unionViews(IN viewname varchar(255),
IN viewname2 varchar(255))
BEGIN
DROP VIEW IF EXISTS tempView;
SET @str = CONCAT('
CREATE VIEW tempView AS
SELECT * FROM ', viewname, ' UNION SELECT * FROM ', viewname2);
PREPARE stmt FROM @str;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET @str2 = CONCAT('DROP VIEW ', viewname, ';');
PREPARE stmt2 FROM @str2;
EXECUTE stmt2;
DEALLOCATE PREPARE stmt2;
SET @str3 = CONCAT('CREATE VIEW ', viewname ,' AS SELECT * FROM tempView');
PREPARE stmt3 FROM @str3;
EXECUTE stmt3;
DEALLOCATE PREPARE stmt3;
END //
DELIMITER ;
DROP view if exists test1;
DROP view if exists test2;
CREATE VIEW test1 as SELECT "Cows";
CREATE VIEW test2 as SELECT "Horses";
CALL SP_unionViews("test1", "test2");
SELECT * from test1;
And its error reads:
#1615 - Prepared statement needs to be re-prepared
mysql stored-procedures prepared-statement union sql-view
I'm creating a MySQL stored procedure that receives the names of two views, and performs a Union upon them into the first of the two.
I've used prepared statements to take view names as strings, so I can use this stored procedure with a wealth of other stored procedures that produce views of varying names.
The following code works as expected:
DROP view if exists test1;
DROP view if exists test2;
CREATE VIEW test1 as SELECT "Cows";
CREATE VIEW test2 as SELECT "Horses";
DROP VIEW if exists tempView;
CREATE VIEW tempView AS SELECT * FROM test1 UNION SELECT * FROM test2;
SELECT * from tempView;
However, when I execute the following code:
DELIMITER //
DROP PROCEDURE IF EXISTS SP_unionViews //
CREATE PROCEDURE SP_unionViews(IN viewname varchar(255),
IN viewname2 varchar(255))
BEGIN
DROP VIEW IF EXISTS tempView;
SET @in1 = viewname;
SET @in2 = viewname2;
SET @str = 'CREATE VIEW tempView AS
SELECT * FROM ? UNION SELECT * FROM ?';
PREPARE stmt FROM @str;
EXECUTE stmt USING @in1, @in2;
SET @str2 = 'DROP VIEW ?';
SET @in3 = viewname;
PREPARE stmt2 FROM @str2;
EXECUTE stmt2 USING @in3;
SET @str3 = 'CREATE VIEW ? AS SELECT * FROM tempView';
PREPARE stmt3 FROM @str3;
EXECUTE stmt3 USING @in3;
DEALLOCATE PREPARE stmt;
DEALLOCATE PREPARE stmt2;
DEALLOCATE PREPARE stmt3;
END //
DELIMITER ;
DROP view if exists test1;
DROP view if exists test2;
CREATE VIEW test1 as SELECT "Cows";
CREATE VIEW test2 as SELECT "Horses";
CALL SP_unionViews(test1, test2);
SELECT * from test1;
I get the following error:
#1054 - Unknown column 'test1' in 'field list'
That would seem to indicate that this stored procedure is trying to use test1 as a column somewhere it's not intended to be one. But I can't figure out where.
UPDATE:
When edited as below, I expected the solution to work, but it gives me another error.
The new code reads:
DELIMITER //
DROP PROCEDURE IF EXISTS SP_unionViews //
CREATE PROCEDURE SP_unionViews(IN viewname varchar(255),
IN viewname2 varchar(255))
BEGIN
DROP VIEW IF EXISTS tempView;
SET @str = CONCAT('
CREATE VIEW tempView AS
SELECT * FROM ', viewname, ' UNION SELECT * FROM ', viewname2);
PREPARE stmt FROM @str;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET @str2 = CONCAT('DROP VIEW ', viewname, ';');
PREPARE stmt2 FROM @str2;
EXECUTE stmt2;
DEALLOCATE PREPARE stmt2;
SET @str3 = CONCAT('CREATE VIEW ', viewname ,' AS SELECT * FROM tempView');
PREPARE stmt3 FROM @str3;
EXECUTE stmt3;
DEALLOCATE PREPARE stmt3;
END //
DELIMITER ;
DROP view if exists test1;
DROP view if exists test2;
CREATE VIEW test1 as SELECT "Cows";
CREATE VIEW test2 as SELECT "Horses";
CALL SP_unionViews("test1", "test2");
SELECT * from test1;
And its error reads:
#1615 - Prepared statement needs to be re-prepared
mysql stored-procedures prepared-statement union sql-view
mysql stored-procedures prepared-statement union sql-view
edited Nov 17 '18 at 8:12
Feygon
asked Nov 17 '18 at 7:19
FeygonFeygon
33
33
btw, please don't worry about the 'Select *' stuff. This is boilerplate.
– Feygon
Nov 17 '18 at 7:28
Edited to fix: "test1", "test2" needed to be string literals.
– Feygon
Nov 17 '18 at 8:14
Also edited to fix: Creating a view didn't like the subquery.
– Feygon
Nov 17 '18 at 8:14
add a comment |
btw, please don't worry about the 'Select *' stuff. This is boilerplate.
– Feygon
Nov 17 '18 at 7:28
Edited to fix: "test1", "test2" needed to be string literals.
– Feygon
Nov 17 '18 at 8:14
Also edited to fix: Creating a view didn't like the subquery.
– Feygon
Nov 17 '18 at 8:14
btw, please don't worry about the 'Select *' stuff. This is boilerplate.
– Feygon
Nov 17 '18 at 7:28
btw, please don't worry about the 'Select *' stuff. This is boilerplate.
– Feygon
Nov 17 '18 at 7:28
Edited to fix: "test1", "test2" needed to be string literals.
– Feygon
Nov 17 '18 at 8:14
Edited to fix: "test1", "test2" needed to be string literals.
– Feygon
Nov 17 '18 at 8:14
Also edited to fix: Creating a view didn't like the subquery.
– Feygon
Nov 17 '18 at 8:14
Also edited to fix: Creating a view didn't like the subquery.
– Feygon
Nov 17 '18 at 8:14
add a comment |
1 Answer
1
active
oldest
votes
You can't use parameters for table names in a prepared statement, so you will need to put the table names into the query string before you prepare the statement. Try changing your queries to these:
SET @str = CONCAT('
CREATE VIEW tempView AS
SELECT * FROM (
SELECT * FROM ', viewname, ' UNION SELECT * FROM ', viewname2, '
)');
SET @str2 = CONCAT('DROP VIEW ', viewname);
SET @str3 = CONCAT('CREATE VIEW ', viewname, ' AS SELECT * FROM tempView');
Once you have done this you will no longer need any parameters to the EXECUTE
s
Are parameters in prepared statements only useful for columns and comparison values, then?
– Feygon
Nov 17 '18 at 7:33
Oh, I see. This is a question of what the '?' can do.
– Feygon
Nov 17 '18 at 7:34
@Feygon they can basically only be used for data literals.
– Nick
Nov 17 '18 at 7:37
@Feygon sorry about the missing)
s, I've edited the answer.
– Nick
Nov 17 '18 at 7:39
New Error. I really thought your solution would work.
– Feygon
Nov 17 '18 at 8:14
|
show 2 more comments
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%2f53349115%2fmaking-a-union-of-views-in-mysql-stored-procedure%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 can't use parameters for table names in a prepared statement, so you will need to put the table names into the query string before you prepare the statement. Try changing your queries to these:
SET @str = CONCAT('
CREATE VIEW tempView AS
SELECT * FROM (
SELECT * FROM ', viewname, ' UNION SELECT * FROM ', viewname2, '
)');
SET @str2 = CONCAT('DROP VIEW ', viewname);
SET @str3 = CONCAT('CREATE VIEW ', viewname, ' AS SELECT * FROM tempView');
Once you have done this you will no longer need any parameters to the EXECUTE
s
Are parameters in prepared statements only useful for columns and comparison values, then?
– Feygon
Nov 17 '18 at 7:33
Oh, I see. This is a question of what the '?' can do.
– Feygon
Nov 17 '18 at 7:34
@Feygon they can basically only be used for data literals.
– Nick
Nov 17 '18 at 7:37
@Feygon sorry about the missing)
s, I've edited the answer.
– Nick
Nov 17 '18 at 7:39
New Error. I really thought your solution would work.
– Feygon
Nov 17 '18 at 8:14
|
show 2 more comments
You can't use parameters for table names in a prepared statement, so you will need to put the table names into the query string before you prepare the statement. Try changing your queries to these:
SET @str = CONCAT('
CREATE VIEW tempView AS
SELECT * FROM (
SELECT * FROM ', viewname, ' UNION SELECT * FROM ', viewname2, '
)');
SET @str2 = CONCAT('DROP VIEW ', viewname);
SET @str3 = CONCAT('CREATE VIEW ', viewname, ' AS SELECT * FROM tempView');
Once you have done this you will no longer need any parameters to the EXECUTE
s
Are parameters in prepared statements only useful for columns and comparison values, then?
– Feygon
Nov 17 '18 at 7:33
Oh, I see. This is a question of what the '?' can do.
– Feygon
Nov 17 '18 at 7:34
@Feygon they can basically only be used for data literals.
– Nick
Nov 17 '18 at 7:37
@Feygon sorry about the missing)
s, I've edited the answer.
– Nick
Nov 17 '18 at 7:39
New Error. I really thought your solution would work.
– Feygon
Nov 17 '18 at 8:14
|
show 2 more comments
You can't use parameters for table names in a prepared statement, so you will need to put the table names into the query string before you prepare the statement. Try changing your queries to these:
SET @str = CONCAT('
CREATE VIEW tempView AS
SELECT * FROM (
SELECT * FROM ', viewname, ' UNION SELECT * FROM ', viewname2, '
)');
SET @str2 = CONCAT('DROP VIEW ', viewname);
SET @str3 = CONCAT('CREATE VIEW ', viewname, ' AS SELECT * FROM tempView');
Once you have done this you will no longer need any parameters to the EXECUTE
s
You can't use parameters for table names in a prepared statement, so you will need to put the table names into the query string before you prepare the statement. Try changing your queries to these:
SET @str = CONCAT('
CREATE VIEW tempView AS
SELECT * FROM (
SELECT * FROM ', viewname, ' UNION SELECT * FROM ', viewname2, '
)');
SET @str2 = CONCAT('DROP VIEW ', viewname);
SET @str3 = CONCAT('CREATE VIEW ', viewname, ' AS SELECT * FROM tempView');
Once you have done this you will no longer need any parameters to the EXECUTE
s
edited Nov 17 '18 at 7:38
answered Nov 17 '18 at 7:27
NickNick
41.8k142444
41.8k142444
Are parameters in prepared statements only useful for columns and comparison values, then?
– Feygon
Nov 17 '18 at 7:33
Oh, I see. This is a question of what the '?' can do.
– Feygon
Nov 17 '18 at 7:34
@Feygon they can basically only be used for data literals.
– Nick
Nov 17 '18 at 7:37
@Feygon sorry about the missing)
s, I've edited the answer.
– Nick
Nov 17 '18 at 7:39
New Error. I really thought your solution would work.
– Feygon
Nov 17 '18 at 8:14
|
show 2 more comments
Are parameters in prepared statements only useful for columns and comparison values, then?
– Feygon
Nov 17 '18 at 7:33
Oh, I see. This is a question of what the '?' can do.
– Feygon
Nov 17 '18 at 7:34
@Feygon they can basically only be used for data literals.
– Nick
Nov 17 '18 at 7:37
@Feygon sorry about the missing)
s, I've edited the answer.
– Nick
Nov 17 '18 at 7:39
New Error. I really thought your solution would work.
– Feygon
Nov 17 '18 at 8:14
Are parameters in prepared statements only useful for columns and comparison values, then?
– Feygon
Nov 17 '18 at 7:33
Are parameters in prepared statements only useful for columns and comparison values, then?
– Feygon
Nov 17 '18 at 7:33
Oh, I see. This is a question of what the '?' can do.
– Feygon
Nov 17 '18 at 7:34
Oh, I see. This is a question of what the '?' can do.
– Feygon
Nov 17 '18 at 7:34
@Feygon they can basically only be used for data literals.
– Nick
Nov 17 '18 at 7:37
@Feygon they can basically only be used for data literals.
– Nick
Nov 17 '18 at 7:37
@Feygon sorry about the missing
)
s, I've edited the answer.– Nick
Nov 17 '18 at 7:39
@Feygon sorry about the missing
)
s, I've edited the answer.– Nick
Nov 17 '18 at 7:39
New Error. I really thought your solution would work.
– Feygon
Nov 17 '18 at 8:14
New Error. I really thought your solution would work.
– Feygon
Nov 17 '18 at 8:14
|
show 2 more comments
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%2f53349115%2fmaking-a-union-of-views-in-mysql-stored-procedure%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
btw, please don't worry about the 'Select *' stuff. This is boilerplate.
– Feygon
Nov 17 '18 at 7:28
Edited to fix: "test1", "test2" needed to be string literals.
– Feygon
Nov 17 '18 at 8:14
Also edited to fix: Creating a view didn't like the subquery.
– Feygon
Nov 17 '18 at 8:14