displaying repetitive results

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Given a database query thats returns results from a linking (or xref)
table which includes repetition because of the joins:

+----+--------------------------+----------+
| id | title                    | subject  |
+----+--------------------------+----------+
|  1 | Collected Poems of Keats | poetry   |
|  2 | Spy High                 | suspense |
|  3 | Sci Fi Spies             | suspense |
|  3 | Sci Fi Spies             | sci-fi   |
+----+--------------------------+----------+

What is the best way to go about displaying this for the user so that
the record looks "complete":

ID: 3
title: Sci Fi Spies
Subjects: suspense, scifi

or something similar? Or is there some better way to query? It's also
a problem in terms of limiting the query because if I limit the query
to 10 records I might be chopping off some subjects for the last book?

The query and tables are simple:

select books.id, books.title, subjects.subject
from books, subjects, books_subjects
where books_subjects.bid = books.id
and books_subjects.sid = subjects.id 

BOOKS
1. collected poems of keats
2. spy high
3. sci-fi spies

SUBJECTS:
1. poetry
2. suspense
3. sci-fi
4. horror
5. mystery

BOOKS_SUBJECTS
bid  sid
1    1
2    2
3    2
3    3 

c

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux