Re: Use Results From a Select as the "From" for Another Select
- From: Hugo Kornelis <hugo@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 01 Apr 2005 22:16:09 +0200
On Fri, 1 Apr 2005 10:09:03 -0800, RitaG wrote:
>Hi.
>
>I have to use a long, complicated "Where" clause in a SQL statement and
>thought it would be better to break it up into 2 Selects but am not sure of
>how to do it.
>
>I'll make my example really simple - I want to select TextData (defined as
>an Image in the SQL table) from a table Where TextData like '%ABC%' AND not
>like '%DEF%'
>AND not like '%GHI%' AND not like '%JKL%' etc.
>
>Basically the question is how to code a Select within another Select where
>the 2nd Select uses the results from the 1st Select.
>
>Here's what I tried which doesn't work (I broke each piece down and they
>work separately but not together):
>Select ProviderName from (Select ProviderName from Provider where
>PPONetworkID like '%9')
>where ProviderName like '%EDEL%'
>
>Any suggrstions will be greatly appreciated.
>Rita
Hi Rita,
You're nearly there! You are right that you can use a query instead of a
table or view (this is called a derived query). The only thing you
forgot is to provide an alias for the derived table. Since it has no
name of it's own, it MUST have an alias - even if you never refer to it.
Select ProviderName from (Select ProviderName from Provider where
PPONetworkID like '%9') AS x
where ProviderName like '%EDEL%'
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)
.
- Follow-Ups:
- References:
- Prev by Date: Re: Query Help with IF stmt
- Next by Date: Re: Use Results From a Select as the "From" for Another Select
- Previous by thread: Use Results From a Select as the "From" for Another Select
- Next by thread: Re: Use Results From a Select as the "From" for Another Select
- Index(es):
Relevant Pages
|
|