Thanks to Beau and Tore for insightful feedback. I will most likely
implement the lookup table logic and do things right from the start rather
than using a band-aid solution.

Rich

-----Original Message-----
From: Beau Hartshorne [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 04, 2003 9:56 PM
To: 'Rich Hutchins'
Cc: [EMAIL PROTECTED]
Subject: RE: Perplexed by reverse SELECT statement.


Hi Rich,

I think that instead of a readBY column in your news table, you should
use what's called a lookup table. In this case, the lookup table would
store the primary key from the news table and the primary key from the
user table. Your table structure might look something like this:

user
----------
user_id
username
password

news
----------
news_id
headline
body

user_news (the lookup table)
----------
user_id
news_id

The data in the user_news table will look something like:

SELECT user_id,news_id FROM user_news;

+---------+---------+
| user_id | news_id |
+---------+---------+
|       1 |       2 |
|       1 |      10 |
|       1 |       9 |
|       2 |      23 |
|       1 |      23 |
+---------+---------+

This means user 1 has read news items 2,10,9 and 23. User 2 has read
only news item 23. With this structure, you should be able to build a
SELECT query to find the information you need.

Beau

> When I do a SELECT of all news items from this news table, I
> want to select only those items that I have not read - ones
> where the user ID 1 is NOT in the readBY column.



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to