Board index » delphi » Union problem with sub-query

Union problem with sub-query

Hi all

I have an SQL that works fine:

SELECT id FROM call
  UNION
  SELECT call_id as id FROM call_task

But when I want to use the same in a sub-Query, it doesn't understand
'UNION'

SELECT * FROM V_CALL WHERE id in
 (SELECT id FROM call
  UNION
  SELECT call_id as id FROM call_task)

Can you help me?

Herbert

 

Re:Union problem with sub-query


In article <3e10a...@newsgroups.borland.com>, hsch...@external.ch says...
Quote
> But when I want to use the same in a sub-Query, it doesn't understand
> 'UNION'

        No, you can't do this.

Quote
> SELECT * FROM V_CALL WHERE id in
>  (SELECT id FROM call
>   UNION
>   SELECT call_id as id FROM call_task)

SELECT * FROM V_CALL
WHERE
  (id in (SELECT id FROM call))
 OR
  (id in (SELECT call_id as id FROM call_task))

        -Craig

--
Craig Stuntz [TeamB] Vertex Systems Corp. Columbus, OH
Delphi/InterBase Weblog : http://delphi.weblogs.com
InterBase Perf. Monitor : http://delphi.weblogs.com/IBPerformanceMonitor
InterBase PLANalyzer 1.1: http://delphi.weblogs.com/IBPLANalyzer

Other Threads