How do you input multiple SELECT outputs into a FROM clause in MySQL?
I want to do something similar to the following in MySQL, but every permutation I try gives me errors.
SELECT five,six FROM (SELECT 5 AS five),(SELECT 6 AS six);
I was under the impression that SELECT's output table's, so that I could use SELECT whereever I could insert a table.
Can someone explain the subtleties of the structre of MySQL that prevents this statement from wo开发者_运维百科rking as well as providing me a solution that does?
I know that it's got to be simple, but I haven't been able to find an answer to this anywhere.
Try adding aliases:
SELECT five, six FROM (SELECT 5 AS five) AS a, ( SELECT 6 AS six) AS b
I don't know what you're trying to accomplish but this works
select five,six from (select 5 as five, 6 as six) as t;
It's obvious useless cause it's the same of
select 5 as five, 6 as six
but I hope that it helps you.
精彩评论