dbTalk Databases Forums  

union in a subquery

comp.databases.sybase comp.databases.sybase


Discuss union in a subquery in the comp.databases.sybase forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jean Legare
 
Posts: n/a

Default union in a subquery - 06-04-2004 , 03:43 PM






Hello:

I need to perform following


select
col1
from
table1
where
col2
in
(select
cola
from
tablea
UNION
select
colb
from
tableb)


I can't do this - get error message


Server Message: Number 156, Severity 15
Server 'x', Line 24:
Incorrect syntax near the keyword 'UNION'.
Server Message: Number 102, Severity 15
Server 'x', Line 45:
Incorrect syntax near ')'.

Reply With Quote
  #2  
Old   
Carl Kayser
 
Posts: n/a

Default Re: union in a subquery - 06-05-2004 , 06:34 AM






Is this with ASA or ASE? (Apparently from the latter.) Which release?

"Jean Legare" <jglegare (AT) hotmail (DOT) com> wrote

Quote:
Hello:

I need to perform following


select
col1
from
table1
where
col2
in
(select
cola
from
tablea
UNION
select
colb
from
tableb)


I can't do this - get error message


Server Message: Number 156, Severity 15
Server 'x', Line 24:
Incorrect syntax near the keyword 'UNION'.
Server Message: Number 102, Severity 15
Server 'x', Line 45:
Incorrect syntax near ')'.



Reply With Quote
  #3  
Old   
Jean Legare
 
Posts: n/a

Default Re: union in a subquery - 06-05-2004 , 04:33 PM



This was on ASE version 12.0.x

J


jglegare (AT) hotmail (DOT) com (Jean Legare) wrote in message news:<68e7005a.0406041243.cedf080 (AT) posting (DOT) google.com>...
Quote:
Hello:

I need to perform following


select
col1
from
table1
where
col2
in
(select
cola
from
tablea
UNION
select
colb
from
tableb)


I can't do this - get error message


Server Message: Number 156, Severity 15
Server 'x', Line 24:
Incorrect syntax near the keyword 'UNION'.
Server Message: Number 102, Severity 15
Server 'x', Line 45:
Incorrect syntax near ')'.

Reply With Quote
  #4  
Old   
Metin Esat
 
Posts: n/a

Default Re: union in a subquery - 06-06-2004 , 04:01 PM



try this, it should work.

(select
x=cola
from
tablea
UNION
select
x=colb
from
tableb)


jglegare (AT) hotmail (DOT) com (Jean Legare) wrote in message news:<68e7005a.0406041243.cedf080 (AT) posting (DOT) google.com>...
Quote:
Hello:

I need to perform following


select
col1
from
table1
where
col2
in
(select
cola
from
tablea
UNION
select
colb
from
tableb)


I can't do this - get error message


Server Message: Number 156, Severity 15
Server 'x', Line 24:
Incorrect syntax near the keyword 'UNION'.
Server Message: Number 102, Severity 15
Server 'x', Line 45:
Incorrect syntax near ')'.

Reply With Quote
  #5  
Old   
Willie Kraatz
 
Posts: n/a

Default Re: union in a subquery - 06-07-2004 , 07:46 AM



Try
select
col1
from
table1
where col2 in (select cola from tablea )
or col2 in (select colb from tableb)


"Jean Legare" <jglegare (AT) hotmail (DOT) com> wrote

Quote:
Hello:

I need to perform following


select
col1
from
table1
where
col2
in
(select
cola
from
tablea
UNION
select
colb
from
tableb)


I can't do this - get error message


Server Message: Number 156, Severity 15
Server 'x', Line 24:
Incorrect syntax near the keyword 'UNION'.
Server Message: Number 102, Severity 15
Server 'x', Line 45:
Incorrect syntax near ')'.



Reply With Quote
  #6  
Old   
Toni Salomäki
 
Posts: n/a

Default Re: union in a subquery - 06-07-2004 , 01:23 PM



In article <ca1o3v$qsb$1 (AT) lore (DOT) csc.com>, Willie Kraatz wrote:
Quote:
Try
select
col1
from
table1
where col2 in (select cola from tablea )
or col2 in (select colb from tableb)


In this solution sybase can't use indexes for col2. If the union does not
work it is at least possible to create temp. table with union and use
that in the in part.

Toni


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.