By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,652 Members | 1,337 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,652 IT Pros & Developers. It's quick & easy.

reference to parent qry

P: n/a
hi,

this is my sql code.
-----start code-----
SELECT Reeksen.ReeksNR, Reeksen.ReeksText, Count(Strips.Titel) AS
NBTitel,

(SELECT Count(strips.Titel) AS AantalVanTitel FROM (Reeksen INNER JOIN
Strips ON Reeksen.ReeksNR = Strips.ReeksNR) INNER JOIN Pictures ON
Strips.Uniek = Pictures.Uniek where reeksen.ReeksNR=11) AS AantalPic

FROM Reeksen INNER JOIN Strips ON Reeksen.ReeksNR = Strips.ReeksNR
GROUP BY Reeksen.ReeksNR, Reeksen.ReeksText;
-----end code-----

somewhere in the middle I need to reference to Reeksen.ReeksNR, the
first field in the statement. like now I always have the same value
for each row. and it shout be different for every row. if I change it
into Reeksen.ReeksNR it always returns the nubre of all records in the
table. Someone has I solution

Thanks Jan
Jun 27 '08 #1
Share this Question
Share on Google+
6 Replies


P: n/a
JR
Sorry in the middel where the 11 stands

<ja********@gmail.comschreef in bericht
news:9a**********************************@2g2000hs n.googlegroups.com...
hi,

this is my sql code.
-----start code-----
SELECT Reeksen.ReeksNR, Reeksen.ReeksText, Count(Strips.Titel) AS
NBTitel,

(SELECT Count(strips.Titel) AS AantalVanTitel FROM (Reeksen INNER JOIN
Strips ON Reeksen.ReeksNR = Strips.ReeksNR) INNER JOIN Pictures ON
Strips.Uniek = Pictures.Uniek where reeksen.ReeksNR=11) AS AantalPic

FROM Reeksen INNER JOIN Strips ON Reeksen.ReeksNR = Strips.ReeksNR
GROUP BY Reeksen.ReeksNR, Reeksen.ReeksText;
-----end code-----

somewhere in the middle I need to reference to Reeksen.ReeksNR, the
first field in the statement. like now I always have the same value
for each row. and it shout be different for every row. if I change it
into Reeksen.ReeksNR it always returns the nubre of all records in the
table. Someone has I solution

Thanks Jan
Jun 27 '08 #2

P: n/a
On Tue, 22 Apr 2008 06:50:47 -0700 (PDT), ja********@gmail.com wrote:

If I understand you correctly you need to reference the parent query
from the top query, and they both use the same tablename "Reeksen".

Simply use an Alias in the subquery:
.... from Reeksen as ReeksenSub
so you can write things like:
.... where Reeksen.SomeField = ReeksenSub.SomeField

-Tom.
>hi,

this is my sql code.
-----start code-----
SELECT Reeksen.ReeksNR, Reeksen.ReeksText, Count(Strips.Titel) AS
NBTitel,

(SELECT Count(strips.Titel) AS AantalVanTitel FROM (Reeksen INNER JOIN
Strips ON Reeksen.ReeksNR = Strips.ReeksNR) INNER JOIN Pictures ON
Strips.Uniek = Pictures.Uniek where reeksen.ReeksNR=11) AS AantalPic

FROM Reeksen INNER JOIN Strips ON Reeksen.ReeksNR = Strips.ReeksNR
GROUP BY Reeksen.ReeksNR, Reeksen.ReeksText;
-----end code-----

somewhere in the middle I need to reference to Reeksen.ReeksNR, the
first field in the statement. like now I always have the same value
for each row. and it shout be different for every row. if I change it
into Reeksen.ReeksNR it always returns the nubre of all records in the
table. Someone has I solution

Thanks Jan
Jun 27 '08 #3

P: n/a
On Tue, 22 Apr 2008 19:58:19 -0700, Tom van Stiphout
<no*************@cox.netwrote:

Oops. I meant "... from the sub query ..."
-Tom.

>On Tue, 22 Apr 2008 06:50:47 -0700 (PDT), ja********@gmail.com wrote:

If I understand you correctly you need to reference the parent query
from the top query, and they both use the same tablename "Reeksen".

Simply use an Alias in the subquery:
... from Reeksen as ReeksenSub
so you can write things like:
... where Reeksen.SomeField = ReeksenSub.SomeField

-Tom.
>>hi,

this is my sql code.
-----start code-----
SELECT Reeksen.ReeksNR, Reeksen.ReeksText, Count(Strips.Titel) AS
NBTitel,

(SELECT Count(strips.Titel) AS AantalVanTitel FROM (Reeksen INNER JOIN
Strips ON Reeksen.ReeksNR = Strips.ReeksNR) INNER JOIN Pictures ON
Strips.Uniek = Pictures.Uniek where reeksen.ReeksNR=11) AS AantalPic

FROM Reeksen INNER JOIN Strips ON Reeksen.ReeksNR = Strips.ReeksNR
GROUP BY Reeksen.ReeksNR, Reeksen.ReeksText;
-----end code-----

somewhere in the middle I need to reference to Reeksen.ReeksNR, the
first field in the statement. like now I always have the same value
for each row. and it shout be different for every row. if I change it
into Reeksen.ReeksNR it always returns the nubre of all records in the
table. Someone has I solution

Thanks Jan
Jun 27 '08 #4

P: n/a
JR
I found some of that info on the net. wat i was missing in all that info was
a way how I must do it. I diden'tonderstand there examples . So how do I
give that query another name

Tom van Stiphout" <no*************@cox.netschreef in bericht
..news:02********************************@4ax.com. ..
On Tue, 22 Apr 2008 19:58:19 -0700, Tom van Stiphout
<no*************@cox.netwrote:

Oops. I meant "... from the sub query ..."
-Tom.

>>On Tue, 22 Apr 2008 06:50:47 -0700 (PDT), ja********@gmail.com wrote:

If I understand you correctly you need to reference the parent query
from the top query, and they both use the same tablename "Reeksen".

Simply use an Alias in the subquery:
... from Reeksen as ReeksenSub
so you can write things like:
... where Reeksen.SomeField = ReeksenSub.SomeField

-Tom.
>>>hi,

this is my sql code.
-----start code-----
SELECT Reeksen.ReeksNR, Reeksen.ReeksText, Count(Strips.Titel) AS
NBTitel,

(SELECT Count(strips.Titel) AS AantalVanTitel FROM (Reeksen INNER JOIN
Strips ON Reeksen.ReeksNR = Strips.ReeksNR) INNER JOIN Pictures ON
Strips.Uniek = Pictures.Uniek where reeksen.ReeksNR=11) AS AantalPic

FROM Reeksen INNER JOIN Strips ON Reeksen.ReeksNR = Strips.ReeksNR
GROUP BY Reeksen.ReeksNR, Reeksen.ReeksText;
-----end code-----

somewhere in the middle I need to reference to Reeksen.ReeksNR, the
first field in the statement. like now I always have the same value
for each row. and it shout be different for every row. if I change it
into Reeksen.ReeksNR it always returns the nubre of all records in the
table. Someone has I solution

Thanks Jan
Jun 27 '08 #5

P: n/a
On Apr 24, 3:59*am, "JR" <xx....@xx.xxwrote:
I found some of that info on the net. wat i was missing in all that info was
a way how I must do it. I diden'tonderstand there examples . So how do I
give that query *another name

Tom van Stiphout" <no.spam.tom7...@cox.netschreef in bericht
.news:02********************************@4ax.com.. .
On Tue, 22 Apr 2008 19:58:19 -0700, Tom van Stiphout
<no.spam.tom7...@cox.netwrote:
Oops. I meant "... from the sub query ..."
-Tom.
>On Tue, 22 Apr 2008 06:50:47 -0700 (PDT), jan.sch...@gmail.com wrote:
>If I understand you correctly you need to reference the parent query
from the top query, and they both use the same tablename "Reeksen".
>Simply use an Alias in the subquery:
... from Reeksen as ReeksenSub
so you can write things like:
... where Reeksen.SomeField = ReeksenSub.SomeField
>-Tom.
>>hi,
>>this is my sql code.
-----start code-----
SELECT Reeksen.ReeksNR, Reeksen.ReeksText, Count(Strips.Titel) AS
NBTitel,
>>(SELECT Count(strips.Titel) AS AantalVanTitel FROM (Reeksen INNER JOIN
Strips ON Reeksen.ReeksNR = Strips.ReeksNR) INNER JOIN Pictures ON
Strips.Uniek = Pictures.Uniek where reeksen.ReeksNR=11) AS AantalPic
>>FROM Reeksen INNER JOIN Strips ON Reeksen.ReeksNR = Strips.ReeksNR
GROUP BY Reeksen.ReeksNR, Reeksen.ReeksText;
-----end code-----
>>somewhere in the middle I need to reference to Reeksen.ReeksNR, the
first field in the statement. like now I always have the same value
for each row. and it shout be different for every row. if I change it
into Reeksen.ReeksNR it always returns the nubre of all records in the
table. Someone has I solution
>>Thanks Jan- Hide quoted text -

- Show quoted text -
because you reference the table Reeksen twice, you need to use an
alias to differentiate between the two, see references to ReeksenSub
below

SELECT ReeksenSub.ReeksNR, ReeksenSub.ReeksText, Count(Strips.Titel)
AS
NBTitel,
(SELECT Count(strips.Titel) AS AantalVanTitel FROM (Reeksen INNER
JOIN
Strips ON Reeksen.ReeksNR = Strips.ReeksNR) INNER JOIN Pictures ON
Strips.Uniek = Pictures.Uniek where reeksen.ReeksNR=11) AS AantalPic
FROM Reeksen as ReeksenSub INNER JOIN Strips ON ReeksenSub.ReeksNR =
Strips.ReeksNR
GROUP BY ReeksenSub.ReeksNR, ReeksenSub.ReeksText;

Jun 27 '08 #6

P: n/a
JR

"Roger" <le*********@natpro.comschreef in bericht
news:27**********************************@m3g2000h sc.googlegroups.com...
On Apr 24, 3:59 am, "JR" <xx....@xx.xxwrote:
I found some of that info on the net. wat i was missing in all that info
was
a way how I must do it. I diden'tonderstand there examples . So how do I
give that query another name

Tom van Stiphout" <no.spam.tom7...@cox.netschreef in bericht
.news:02********************************@4ax.com.. .
On Tue, 22 Apr 2008 19:58:19 -0700, Tom van Stiphout
<no.spam.tom7...@cox.netwrote:
Oops. I meant "... from the sub query ..."
-Tom.
>On Tue, 22 Apr 2008 06:50:47 -0700 (PDT), jan.sch...@gmail.com wrote:
>If I understand you correctly you need to reference the parent query
from the top query, and they both use the same tablename "Reeksen".
>Simply use an Alias in the subquery:
... from Reeksen as ReeksenSub
so you can write things like:
... where Reeksen.SomeField = ReeksenSub.SomeField
>-Tom.
>>hi,
>>this is my sql code.
-----start code-----
SELECT Reeksen.ReeksNR, Reeksen.ReeksText, Count(Strips.Titel) AS
NBTitel,
>>(SELECT Count(strips.Titel) AS AantalVanTitel FROM (Reeksen INNER JOIN
Strips ON Reeksen.ReeksNR = Strips.ReeksNR) INNER JOIN Pictures ON
Strips.Uniek = Pictures.Uniek where reeksen.ReeksNR=11) AS AantalPic
>>FROM Reeksen INNER JOIN Strips ON Reeksen.ReeksNR = Strips.ReeksNR
GROUP BY Reeksen.ReeksNR, Reeksen.ReeksText;
-----end code-----
>>somewhere in the middle I need to reference to Reeksen.ReeksNR, the
first field in the statement. like now I always have the same value
for each row. and it shout be different for every row. if I change it
into Reeksen.ReeksNR it always returns the nubre of all records in the
table. Someone has I solution
>>Thanks Jan- Hide quoted text -

- Show quoted text -
because you reference the table Reeksen twice, you need to use an
alias to differentiate between the two, see references to ReeksenSub
below

SELECT ReeksenSub.ReeksNR, ReeksenSub.ReeksText, Count(Strips.Titel)
AS
NBTitel,
(SELECT Count(strips.Titel) AS AantalVanTitel FROM (Reeksen INNER
JOIN
Strips ON Reeksen.ReeksNR = Strips.ReeksNR) INNER JOIN Pictures ON
Strips.Uniek = Pictures.Uniek where reeksen.ReeksNR=11) AS AantalPic
FROM Reeksen as ReeksenSub INNER JOIN Strips ON ReeksenSub.ReeksNR =
Strips.ReeksNR
GROUP BY ReeksenSub.ReeksNR, ReeksenSub.ReeksText;
thanks. now I get it

Jun 27 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.