J
jfancy-Transport Canada
Hi,
I'm building a subscribers database for a client. There are six
different categories. 0 to 6. I need to return those names that are
subscribed to ALL 7 of the categories. He/She cannot show up if, say,
he/she is subscribed to 5 categories. It needs to be a query so that
the client can see the subscribers in a table that are subscribed to
all 7 categories. This is the code I have come up with but doesn't
work. It returns nothing.
------------------------------------------------------------------
SELECT name
FROM SUBSCRIBER_LIST
WHERE category_id = 0 AND category_id = 1, AND category_id = 2, AND
category_id = 3, AND category_id = 4, AND category_id = 5, AND
category_id = 6;
------------------------------------------------------------------
I get the idea that the AND is wrong, because maybe it is comparing one
record to all these id's and returning nothing because in one record,
the category id does not equal 0,1,2,3,4,5 and 6.
Also, I need a query to display only those who are only subscribed to
ONE list only. Now, there are duplicates in the database due to
subscriber dates, so its difficult.
I'm building a subscribers database for a client. There are six
different categories. 0 to 6. I need to return those names that are
subscribed to ALL 7 of the categories. He/She cannot show up if, say,
he/she is subscribed to 5 categories. It needs to be a query so that
the client can see the subscribers in a table that are subscribed to
all 7 categories. This is the code I have come up with but doesn't
work. It returns nothing.
------------------------------------------------------------------
SELECT name
FROM SUBSCRIBER_LIST
WHERE category_id = 0 AND category_id = 1, AND category_id = 2, AND
category_id = 3, AND category_id = 4, AND category_id = 5, AND
category_id = 6;
------------------------------------------------------------------
I get the idea that the AND is wrong, because maybe it is comparing one
record to all these id's and returning nothing because in one record,
the category id does not equal 0,1,2,3,4,5 and 6.
Also, I need a query to display only those who are only subscribed to
ONE list only. Now, there are duplicates in the database due to
subscriber dates, so its difficult.