Subject Correlated Sub Query question
Author Martin Catherall
Hi,

I am trying to do a correlated sub query, in the select.

This works fine, except I want to make the sub query reference the main
query. I tried to use an alias in the main query and reference that
alias in the sub query nu firebird gave me an error..

I have included the query below. You will see that the where clause of
the sub query is trying to reference an alias from the "outer query"
(ScheduleID)
(when the scheduleID alias is replaced with a number then all works
fine)
is this sort of thing possible in firbird and if so how do I use it.

SELECT
EE_SP_SCHEDULE.ID ScheduleID,
EE_SP_SCHEDULE.CAMPAIGN_NAME,
EE_SECURITY.USER_NAME,
EE_SECURITY.EMAIL_ADDRESS,
(
SELECT COUNT( * )
FROM EE_SP_SCHEDULE
INNER JOIN EE_SP_SCHEDULE_TIME ON (EE_SP_SCHEDULE.ID =
EE_SP_SCHEDULE_TIME.EE_SP_SCHEDULE_ID)
INNER JOIN EE_MESSAGE ON (EE_SP_SCHEDULE_TIME.ID =
EE_MESSAGE.EE_SP_SCHEDULE_TIME_ID)
where EE_SP_SCHEDULE.ID = ScheduleID
)
FROM EE_SP_SCHEDULE
INNER JOIN EE_SECURITY ON (EE_SP_SCHEDULE.EE_SECURITY_ID =
EE_SECURITY.ID)

thank you in advance for your help.

cheers

martin.


Check out www.ubique.webscape.co.nz <http://www.ubique.webscape.co.nz/>
Ubique --> "Drives Your Business"

W E B S C A P E
PO Box 22571
25 Carlyle Street
Christchurch
http://www.webscape.co.nz <http://www.webscape.co.nz/>

Phone 03 964 4020
Fax 03 365 9115
Email mc@... <mailto:tmc@...>

-----Original Message-----
From: Martijn Tonies [mailto:m.tonies@...]
Sent: Saturday, 3 April 2004 1:26 a.m.
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] unsubscribe





> "What do I have to do to unsubscribe this list?"

At the end of every email in this list:

> Yahoo! Groups Links
>
>
>

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird,
MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com



_____

Yahoo! Groups Links


* To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

* To unsubscribe from this group, send an email to:
firebird-support-unsubscribe@yahoogroups.com
<mailto:firebird-support-unsubscribe@yahoogroups.com?subject=Unsubscribe
>

* Your use of Yahoo! Groups is subject to the Yahoo! Terms
of Service <http://docs.yahoo.com/info/terms/> .



=========================================================
This e-mail has been scanned for Viruses and Content and cleared by NetIQ MailMarshal


[Non-text portions of this message have been removed]