displaying repetitive results

From: Date: Wed, 10 Nov 2004 18:04:27 +0000
Subject: displaying repetitive results
Groups: php.general 
Request: Send a blank email to php-general+get-201708@lists.php.net to get a copy of this message
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

« previous php.general (#201708) next »