This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Dreamweaver > September 2005 > SQL Help





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author SQL Help
Daniel Reyes

2005-09-15, 7:19 pm

Hello,

I have a DB Table "Cats" with Categories and subcategories: "CatID" -
"CatName" - "ParentID"

I want to select the "CatName" where the "CatID" = "ParentID" of the row
selected by "Recordset__MMColParam" if "Parent ID" is not "0"

Something like this !?

SELECT CatName FROM Cats WHERE CatID = ParentID WHERE CATID = " +
Replace(Recordset__MMColParam, "'", "''") + "" AND ParID <> "0"

Any help much appreciated !

Regards,
Daniel


Lionstone

2005-09-15, 7:19 pm

And if parent ID is 0, what do you want to do? The query below will return
the record selected by MMColParam if the parent ID of that record 0, else it
will return the parent record.

SELECT CatName FROM Cats WHERE CatID = ISNULL(NULLIF((SELECT ParentID FROM
Cats WHERE CatID=MMColParam),0),MMColParam)

I didn't do all the string breaking and stuff; you should be able to paste
that in the Recordset dialog design view and have DW take care of the
details.


"Daniel Reyes" <daniel@caboverde24.com> wrote in message
news:dgbn09$keg$1@forums.macromedia.com...
> Hello,
>
> I have a DB Table "Cats" with Categories and subcategories: "CatID" -
> "CatName" - "ParentID"
>
> I want to select the "CatName" where the "CatID" = "ParentID" of the row
> selected by "Recordset__MMColParam" if "Parent ID" is not "0"
>
> Something like this !?
>
> SELECT CatName FROM Cats WHERE CatID = ParentID WHERE CATID = " +
> Replace(Recordset__MMColParam, "'", "''") + "" AND ParID <> "0"
>
> Any help much appreciated !
>
> Regards,
> Daniel
>



Daniel Reyes

2005-09-15, 7:19 pm

If ParentID=0 I don´t want any records to be shown, I want only the parent
record of record where ParentID is NOT null.
I´m still not able to fix this SQL...I´m not so good at this stuff...
Don´t know ISNULL and NULLIF - do I have to convert something there ?

Thanks
Daniel


"Lionstone" <HIDElionstone@HIDEhushmail.com> wrote in message
news:dgbtb9$p8$1@forums.macromedia.com...
> And if parent ID is 0, what do you want to do? The query below will
> return the record selected by MMColParam if the parent ID of that record
> 0, else it will return the parent record.
>
> SELECT CatName FROM Cats WHERE CatID = ISNULL(NULLIF((SELECT ParentID FROM
> Cats WHERE CatID=MMColParam),0),MMColParam)
>
> I didn't do all the string breaking and stuff; you should be able to paste
> that in the Recordset dialog design view and have DW take care of the
> details.
>
>
> "Daniel Reyes" <daniel@caboverde24.com> wrote in message
> news:dgbn09$keg$1@forums.macromedia.com...
>
>



Daniel Reyes

2005-09-15, 7:19 pm

I get this error:
Wrong number of arguments used with function in quer expression
CatID = ISNULL(NULLIF((SELECT ParID FROM Cats WHERE CatID=110),0),110)


"Daniel Reyes" <daniel@caboverde24.com> wrote in message
news:dgc0ij$63g$1@forums.macromedia.com...
> If ParentID=0 I don´t want any records to be shown, I want only the parent
> record of record where ParentID is NOT null.
> I´m still not able to fix this SQL...I´m not so good at this stuff...
> Don´t know ISNULL and NULLIF - do I have to convert something there ?
>
> Thanks
> Daniel
>
>
> "Lionstone" <HIDElionstone@HIDEhushmail.com> wrote in message
> news:dgbtb9$p8$1@forums.macromedia.com...
>
>



Lionstone

2005-09-15, 7:19 pm

What's your database? That won't work on all of them.
But if you want no records if the parent ID = 0 then it's not as
complicated.

SELECT CatName FROM Cats WHERE CatID = (SELECT ParentID FROM
Cats WHERE CatID=MMColParam)

If ParentID is 0, then no category will be returned (unless you have a
category 0, but that's unusual).


"Daniel Reyes" <daniel@caboverde24.com> wrote in message
news:dgc11e$6r7$1@forums.macromedia.com...
>I get this error:
> Wrong number of arguments used with function in quer expression
> CatID = ISNULL(NULLIF((SELECT ParID FROM Cats WHERE CatID=110),0),110)
>
>
> "Daniel Reyes" <daniel@caboverde24.com> wrote in message
> news:dgc0ij$63g$1@forums.macromedia.com...
>
>



Daniel Reyes

2005-09-15, 7:21 pm

GREAT !! That did it !
A THOUSAND thanks , I was desperatley stuck with this !

Regards,
Daniel


"Lionstone" <HIDElionstone@HIDEhushmail.com> wrote in message
news:dgc416$bf9$1@forums.macromedia.com...
> What's your database? That won't work on all of them.
> But if you want no records if the parent ID = 0 then it's not as
> complicated.
>
> SELECT CatName FROM Cats WHERE CatID = (SELECT ParentID FROM
> Cats WHERE CatID=MMColParam)
>
> If ParentID is 0, then no category will be returned (unless you have a
> category 0, but that's unusual).
>
>
> "Daniel Reyes" <daniel@caboverde24.com> wrote in message
> news:dgc11e$6r7$1@forums.macromedia.com...
>
>



Daniel Reyes

2005-09-15, 7:21 pm

Now I get this: Either BOF or EOF is True, or the current record has been
deleted. Requested operation requires a current record.
for records with ParentID=0
I remember there was something to simply switch off this error message and
let the page open normally...can you point me into the right direction ?


"Daniel Reyes" <daniel@caboverde24.com> wrote in message
news:dgc5gu$do8$1@forums.macromedia.com...
> GREAT !! That did it !
> A THOUSAND thanks , I was desperatley stuck with this !
>
> Regards,
> Daniel
>
>
> "Lionstone" <HIDElionstone@HIDEhushmail.com> wrote in message
> news:dgc416$bf9$1@forums.macromedia.com...
>
>



Daniel Reyes

2005-09-15, 7:21 pm

Hey, I remembered now:

While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))

Wend

"Daniel Reyes" <daniel@caboverde24.com> wrote in message
news:dgc5r6$eac$1@forums.macromedia.com...
> Now I get this: Either BOF or EOF is True, or the current record has been
> deleted. Requested operation requires a current record.
> for records with ParentID=0
> I remember there was something to simply switch off this error message and
> let the page open normally...can you point me into the right direction ?
>
>
> "Daniel Reyes" <daniel@caboverde24.com> wrote in message
> news:dgc5gu$do8$1@forums.macromedia.com...
>
>



Lionstone

2005-09-15, 7:21 pm

Or, if you know there's only going to be one record, you can just say

If NOT recordset1.EOF Then

End If


"Daniel Reyes" <daniel@caboverde24.com> wrote in message
news:dgc6nr$foj$1@forums.macromedia.com...
> Hey, I remembered now:
>
> While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
>
> Wend
>
> "Daniel Reyes" <daniel@caboverde24.com> wrote in message
> news:dgc5r6$eac$1@forums.macromedia.com...
>
>



Daniel Reyes

2005-09-15, 7:21 pm

strange that I get this error now:

Response object error 'ASP 0251 : 80004005'

Response Buffer Limit Exceeded

/test/BShowCategory2.asp, line 0

Execution of the ASP page caused the Response Buffer to exceed its
configured limit.



Any idea?

Regards,

Daniel

"Lionstone" <HIDElionstone@HIDEhushmail.com> wrote in message
news:dgc6t9$fud$1@forums.macromedia.com...
> Or, if you know there's only going to be one record, you can just say
>
> If NOT recordset1.EOF Then
>
> End If
>
>
> "Daniel Reyes" <daniel@caboverde24.com> wrote in message
> news:dgc6nr$foj$1@forums.macromedia.com...
>
>



Daniel Reyes

2005-09-15, 7:21 pm

Ohhh, your code solved the problem !!
Thanks again ! GREAT I´m done !

Regards,
Daniel


"Daniel Reyes" <daniel@caboverde24.com> wrote in message
news:dgc741$g7m$1@forums.macromedia.com...
> strange that I get this error now:
>
> Response object error 'ASP 0251 : 80004005'
>
> Response Buffer Limit Exceeded
>
> /test/BShowCategory2.asp, line 0
>
> Execution of the ASP page caused the Response Buffer to exceed its
> configured limit.
>
>
>
> Any idea?
>
> Regards,
>
> Daniel
>
> "Lionstone" <HIDElionstone@HIDEhushmail.com> wrote in message
> news:dgc6t9$fud$1@forums.macromedia.com...
>
>



Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews