Re: mySQL relations query

From: Date: Wed, 06 Nov 2002 03:47:57 +0000
Subject: Re: mySQL relations query
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-122926@lists.php.net to get a copy of this message
Well, if both tables are in the same database: select * from books inner join publishers on books.publisherid = publishers.publisherid this assumes that the key for the publisher is publisherid and that publisherid also appears in the book table. This gives you a result set that contains the appropriate information from both tables merged. Marco ----------- php|architect -- The Monthly Magazine For PHP Professionals Visit us on the web at http://www.phparch.com! On Wed, 6 Nov 2002, Edgard Berendsen wrote: > I know this can be a little out of topic but: > > I have a books database and each book belongs to a publisher. > There is also a publisher database with information like (name, > location, etc). In the books database there is a key to identify the > publisher. > > I need a mySQL query for showing each book with each publisher > name and location. > > I don't want to do it using nested loops in .php because I think that > using a "master" SQL query that can access both tables (all inside mySQL) > and their relations can be much faster. > > Thanks > > > > >

« previous php.general (#122926) next »