Re: select from two tables

From: Date: Sat, 27 Jul 2002 15:12:40 +0000
Subject: Re: select from two tables
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-20838@lists.php.net to get a copy of this message
Hi Barry > $query = "SELECT * FROM xoops_album,xoops_artist WHERE > xoops_album.artist_id = xoops_artist.artist_id"; If you only need two fields, it is not necessary to retrieve all fields $query = "SELECT xoops_album.album, xoops_artist.artist FROM xoops_album, xoops_artist WHERE xoops_album.artist_id = xoops_artist.artist_id"; $albumby = mysql_query($query) or die("Select Failed!"); Your resultset contains then the only two required fields. echo"<td><center>"; if (mysql_num_rows($albumr)) { while ($album = mysql_fetch_array($albumr)) { echo "$album[album] <i>by $album[artist] </i><br>"; // new line } echo "</center></td>"; } Hope it helps Conni

« previous php.db (#20838) next »