RE: [PHP-DB] Re: NEWBIE - Needs Assistance with Joins

From: Date: Mon, 17 Sep 2001 15:09:06 +0000
Subject: RE: [PHP-DB] Re: NEWBIE - Needs Assistance with Joins
Groups: php.db 
Request: Send a blank email to php-db+get-12498@lists.php.net to get a copy of this message
SELECT artist_name, album_title FROM album_titles LEFT JOIN artist USING(aid) WHERE artist_id = aid -----Original Message----- From: Michael Egan [mailto:michael@threetc.uklinux.net] Sent: Monday, September 17, 2001 8:22 AM To: php-db@lists.php.net; Cecily Walker Kidd Subject: [PHP-DB] Re: NEWBIE - Needs Assistance with Joins Cecily, I think yuo need to specify the fields within the tables when you write out a select query from multiple tables like this. For example: "SELECT artist_name.*, album_title.* ". "FROM artists, album_titles WHERE artist_name.artist_id = aid"); Hope this works, Michael Cecily Walker Kidd wrote: > > Hello, > > I have two tables, one that contains an item id, album title name, and > artist ID number. The second table is a list of artists, with an > auto-increment artist ID. > > I want to join the two tables and have them output to a single PHP page. > I was following along with the tutorial at > http://www.webmasterbase.com/article/228/, and tried to modify > it for my > own needs. When I do this, I get a parse error on the line that starts > with SELECT. Here's the code: > > $Link = mysql_connect ($Host, $User, $Password); > > $CDList =mysql_query( > "SELECT artist_name, album_title ". > "FROM artists, album_titles WHERE artist_id = aid"); > > > What am I doing wrong? > > Thanks in advance. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#12498) next »