开发者

How do you input multiple SELECT outputs into a FROM clause in MySQL?

开发者 https://www.devze.com 2023-02-19 08:53 出处:网络
I want to do something similar to the following in MySQL, but every permutation I try gives me errors.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消