In Postgre, why does
select abc from (select 1) as abc
produces:
(1)
and
select * from (select 1) as abc
produces:
1
That's really strange to me. Is that the case with MySQL, Oracle, etc? I spent hours figuring out why my conditions were failing...
From stackoverflow
-
What does
select foo from ( select 1 foo ) as abcproduce?
presario : did you mean? select foo from ( select 1 as foo ) as abc i guess so, anyway i got it, thanks -
The rows returned by your queries have different type: the first one is
ROW(INT), while the second one isINT.MySQLand others lack this feature.In your first query, you are selecting a whole
ROWas a single column. This querySELECT abc FROM (SELECT 1, 2) abcwill produce
(1, 2), which is a single column too and has typeROW.To select the
INTvalue, use:SELECT abc.col FROM ( SELECT 1 AS col ) abcpresario : aha! so that's a feature, not a bug! thanks! got it now
0 comments:
Post a Comment