Subject | Re: [firebird-support] unions in sub-selects |
---|---|
Author | Helen Borrie |
Post date | 2005-02-09T04:35:20Z |
At 04:00 AM 9/02/2005 +0000, you wrote:
return 0 or 1 row.
select t1.* from Table1 t1
where EXISTS (
select 1 from Table2 t2
where t2.Table1_ID = t1.Table1_ID)
OR EXISTS (
select 1 from Table3 t3
where t3.Table1_ID = t1.Table1_ID)
./hb
>FB balks at doing a union in a subquery, e.g.:Yes, of course, because a union implies multiple rows and a subquery MUST
>
>select * from Table1
>where Table1_ID in (Select Table1_ID from Table2 union Select
>Table1_ID from Table3)
return 0 or 1 row.
>Is the only way to achieve that via a stored procedure?Probably, but it's not necessary. You can just replace your query with this:
select t1.* from Table1 t1
where EXISTS (
select 1 from Table2 t2
where t2.Table1_ID = t1.Table1_ID)
OR EXISTS (
select 1 from Table3 t3
where t3.Table1_ID = t1.Table1_ID)
./hb