Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Displaying records that don't match.


Message #1 by "scott frank" <scott@w...> on Tue, 8 Oct 2002 04:15:15
I've got two tables.  newsCat and userNewsCat.
newsCat contains the available categories where the key is NID.  
userNewsCat is the categories a user subscribes to containing both NID and 
userName.
I want to be able to display the record that a user HAS NOT subscribed to 
from the newsCat table.  The only way I am able to successfully compare 
the 2 tables is using the check boxes.
Message #2 by "Ken Schaefer" <ken@a...> on Tue, 8 Oct 2002 14:46:10 +1000
SELECT
    a.NID
FROM
    NewsCat AS a
WHERE
    NOT EXISTS
    (
        SELECT
            NULL
        FROM
            UserNewsCat AS b
        WHERE
            a.NID = b.NID
        AND
            b.UserID = 1
    )

Will return a set of NIDs from NewsCat which are not subscribed to by user
with userID 1

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "scott frank" <scott@w...>
Subject: [asp_web_howto] Displaying records that don't match.


: I've got two tables.  newsCat and userNewsCat.
: newsCat contains the available categories where the key is NID.
: userNewsCat is the categories a user subscribes to containing both NID and
: userName.
: I want to be able to display the record that a user HAS NOT subscribed to
: from the newsCat table.  The only way I am able to successfully compare
: the 2 tables is using the check boxes.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Message #3 by "scott frank" <scott@w...> on Tue, 8 Oct 2002 21:43:17
Thanks, Ken.  This works real nice.

> SELECT
    a.NID
FROM
    NewsCat AS a
WHERE
    NOT EXISTS
    (
        SELECT
            NULL
        FROM
            UserNewsCat AS b
        WHERE
            a.NID = b.NID
        AND
            b.UserID = 1
    )

Will return a set of NIDs from NewsCat which are not subscribed to by user
with userID 1

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "scott frank" <scott@w...>
Subject: [asp_web_howto] Displaying records that don't match.


: I've got two tables.  newsCat and userNewsCat.
: newsCat contains the available categories where the key is NID.
: userNewsCat is the categories a user subscribes to containing both NID 
and
: userName.
: I want to be able to display the record that a user HAS NOT subscribed to
: from the newsCat table.  The only way I am able to successfully compare
: the 2 tables is using the check boxes.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


  Return to Index