List:General Discussion« Previous MessageNext Message »
From:Colin McKinnon Date:June 6 2000 8:55am
Subject:Re: [PHP3] Use more than one table in MySQL
View as plain text  
At 19:02 03/06/00 +0800, Andy W. K. Chan wrote:
>   I am new in php and mysql. I know how to use one database and  one
>table. But I don't know how to use more than one table at the same time.
>For  example,    Book_DB - Database   Books - Table key_books key_authors
>key_publishers book_title   Publishers - Table key_publishers
>publisher_name   Autors - Table key_authors author_name author_phone   I
>use the key_???? to link up all table. but I don't know how  to use php to
>insert the data cross all table.   Best Regards, Andy

This is way off topic Andy; this is a question about SQL. Search the MySQL
mailing list archive for 'SQL' and 'tutorial', there have been several
posts to that list on the subject.

To answer your question - you can't do it in a single operation. Think
about the relationship between books, publishers and authors; there is a
1:n relationship between publishers and books, and a 1:n relationship
between authors and books. books decomposes the relationship between
authors and publishers (there is an implicit n:m relationship between books
and authors). One would normally insert a recod in the '1' side (if
necessary) then insert records in the 'n' side. i.e. don't create a book
record before you've created the publisher and author records.

i.e. you need at least 3 operations for a new book from an existing
publisher/author (search publishers, search authors, insert book), and 5
for a new publisher, author and book (search, insert publisher, search,
insert author, insert book).



Use more than one table in MySQLAndy W. K. Chan3 Jun
  • Re: Use more than one table in MySQLsinisa3 Jun
  • Re: [PHP3] Re: Use more than one table in MySQLEgon Schmid3 Jun
  • Re: [PHP3] Use more than one table in MySQLColin McKinnon6 Jun