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

2001-09-17 Thread Rick Emery

SELECT artist_name, album_title FROM album_titles LEFT JOIN artist
USING(aid) WHERE artist_id = aid

-Original Message-
From: Michael Egan [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 17, 2001 8:22 AM
To: [EMAIL PROTECTED]; 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: [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]




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

2001-09-17 Thread biorn

You should not need the extra semicolon in there to complete the SQL
statement.  All you need is the one at the end.

  

Vera Algoet [EMAIL PROTECTED] said:

 Cecily,
 I'm sure you probably heard from others about your parse error. I know 
 it looks weird, but you need to have two semicolons, so instead of:
 
  $CDList =mysql_query(
  SELECT artist_name, album_title .
  FROM artists, album_titles WHERE artist_id = aid);
 
 you would have
 $CDList =mysql_query(
 SELECT artist_name, album_title .
 FROM artists, album_titles WHERE artist_id = aid;);
 
 (Note the semicolon after aid). This is because the first one is to 
 complete the SQL statement, while the one after the parenthisis is to 
 complete the PHP statement.
 
 Vera
 ---
 Madness takes its toll. Please have exact change.
 
 Vera Algoet, Web Developer
 Monterey County Office of Education
 831-784-4169
 



-- 




-- 
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]




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

2001-09-17 Thread Sheridan Saint-Michel

No, the only time you need a semicolon within the query string is if you are
performing
multiple commands.

ie $query=Set @count=0; Select name,@count=@count+1 as count from people;

Sheridan Saint-Michel
Website Administrator
FoxJet, an ITW Company
www.foxjet.com


- Original Message -
From: Vera Algoet [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; Cecily Walker Kidd [EMAIL PROTECTED]
Sent: Monday, September 17, 2001 12:10 PM
Subject: [PHP-DB] Re: NEWBIE - Needs Assistance with Joins


 Cecily,
 I'm sure you probably heard from others about your parse error. I know
 it looks weird, but you need to have two semicolons, so instead of:

  $CDList =mysql_query(
  SELECT artist_name, album_title .
  FROM artists, album_titles WHERE artist_id = aid);

 you would have
 $CDList =mysql_query(
 SELECT artist_name, album_title .
 FROM artists, album_titles WHERE artist_id = aid;);

 (Note the semicolon after aid). This is because the first one is to
 complete the SQL statement, while the one after the parenthisis is to
 complete the PHP statement.

 Vera
 ---
 Madness takes its toll. Please have exact change.

 Vera Algoet, Web Developer
 Monterey County Office of Education
 831-784-4169



-- 
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]




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

2001-09-17 Thread Matthew Loff


There should -not- be a semicolon at the end of the SQL query when using
mysql_query() through PHP... 

http://www.php.net/manual/en/function.mysql-query.php

The problem lies elsewhere.


-Original Message-
From: Vera Algoet [mailto:[EMAIL PROTECTED]] 
Sent: Monday, September 17, 2001 1:11 PM
To: [EMAIL PROTECTED]; Cecily Walker Kidd
Subject: [PHP-DB] Re: NEWBIE - Needs Assistance with Joins 


Cecily,
I'm sure you probably heard from others about your parse error. I know 
it looks weird, but you need to have two semicolons, so instead of:

 $CDList =mysql_query(
 SELECT artist_name, album_title .
 FROM artists, album_titles WHERE artist_id = aid);

you would have
$CDList =mysql_query(
SELECT artist_name, album_title .
FROM artists, album_titles WHERE artist_id = aid;);

(Note the semicolon after aid). This is because the first one is to 
complete the SQL statement, while the one after the parenthisis is to 
complete the PHP statement.

Vera
---
Madness takes its toll. Please have exact change.

Vera Algoet, Web Developer
Monterey County Office of Education
831-784-4169


-- 
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]