Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sybase - Subquery in FROM clause

Tags:

sql

sap-ase

I'm using Sybase ASE 12.5.0.3 and I'm unable to do subqueries like:

select * from (select '1' union select '2' ) X

I've been looking around and as far as I know it should be possible after Sybase ASE 12, am I doing something wrong, or is it not possible with this version???

Edit - Even after changing the query to:

select * from (select '1' as col1 union select '2' as col1 ) X

So even giving alias to the columns, it fails anyways...

like image 546
DarkAjax Avatar asked Oct 14 '25 07:10

DarkAjax


2 Answers

Without seeing an error message, it appears that you need to give column aliases in your sub-query:

select * 
from 
(
    select '1' as yournewCol 
    union 
    select '2' as yournewCol
) X
like image 92
Taryn Avatar answered Oct 16 '25 21:10

Taryn


You need to give your columns name. Try this:

like image 40
Gordon Linoff Avatar answered Oct 16 '25 19:10

Gordon Linoff



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!