[thelist] something wrong with my SQL query

Tom Dell'Aringa pixelmech at yahoo.com
Wed Nov 20 13:27:01 CST 2002


--- rudy <r937 at interlog.com> wrote:
> > You need to check (mysql_num_rows($result) > 0)
>
> tom, if you just want to find out whether the category is being
> used,
> you don't need return all the items like you're doing with this --
>
>    SELECT item
>         FROM menuitem
>             WHERE categoryID =  $id
>
> do this instead --
>
>   SELECT count(*) as numberofitems
>         FROM menuitem
>             WHERE categoryID =  $id
>
> this will always return exactly one row, so then you just test the
> count

Actually, (I probably didn't make this clear) that would return as
many as there are of that category. There could be 12 items of
category 'lunch', (id=4 say) and so it would return 12..not one.
Unless I have completely misunderstood...(which is entirely possible)

Tom

=====
var me = tom.pixelmech.webDeveloper();

http://www.pixelmech.com/
http://www.maccaws.com/
[Making A Commercial Case for Adopting Web Standards]

__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com



More information about the thelist mailing list