Yes you can do that (that's what relational databases are all about).

To join the two tables and fetch the data you need in a single query you
would do something like this:

SELECT Book.*, Chapter.*
FROM Book, Chapter
WHERE Book.BookTitle = Chapter.BookTitle

Where "BookTitle" is whatever common element or key you have in both tables
(this may be the title of the book, or a book ID, etc)

- Patrick


----- Original Message -----
From: "George Pitcher" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, January 18, 2002 8:37 AM
Subject: [PHP-DB] 1 query or 2 queries


> I  have a page that displays a book and some of its chapters (not all
> chapters are recorded) and I want to do a layout like this:
>
> ISN:               012345678X
> Book Title:      A Christmas Carol
> Book Author:  Dickens, C.
> Publisher:        Victorian Press
> Year:              1934
>
> Dickens, C     Chapter One:title     1-33      Last sold for 5p per page
> Digitised
> Dickens, C     Chapter Two:title    34-43     Last sold for 5p per page
> Digitised
> Dickens, C     Chapter Three:title  44-63     Not Cleared
> Not Digitised
> Dickens, C     Chapter Six :title     92-114   Last sold for 5p per page
> Digitised
>
> Now, I know I could do 2 queries, 1 against the book table and the other
> against the chapter table. Would it be possible and if so more efficient
to
> combine them into a single query and still be able to display in this way?
>
> MTIA
>
> George in Edinburgh (data is fictional in more ways than one)
>
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.314 / Virus Database: 175 - Release Date: 11/01/02
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to