Jump to content


Photo

Not unique table/alias


  • Please log in to reply
6 replies to this topic

#1 Sware

Sware
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 03 July 2006 - 01:25 AM

I was doing fine and all of a sudden..

Bam!
Not unique table/alias: 'phpbb_posts'

I'm new to MySQL and trying to create a portal with phpBB.

$query = "SELECT phpbb_posts.poster_id, phpbb_users.username ".
"FROM phpbb_posts, phpbb_users".
"WHERE phpbb_posts.poster_id = phpbb_users.poster_id";

$result = mysql_query($query) or die(mysql_error());


// Print out the contents of each row into a table
while($row = mysql_fetch_array($result)){
echo $row['poster_id'];
echo $row['username'];
echo "<br />";
}

Just a little test but it shows that error, ANY help will be thanked for.

#2 Sware

Sware
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 03 July 2006 - 03:04 AM

Bump - Looked at once, not cool.

#3 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 03 July 2006 - 05:26 AM

That is an unusual error... do you get the same error when you convert that query to proper join syntax?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#4 Sware

Sware
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 03 July 2006 - 05:29 AM

$query = "SELECT phpbb_posts.poster_id, phpbb_users.username FROM phpbb_posts, phpbb_users WHERE phpbb_posts.poster_id = phpbb_users.poster_id"; 

something like that? yes.

#5 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 03 July 2006 - 05:35 AM

No, something like:

SELECT phpbb_posts.poster_id, phpbb_users.username FROM phpbb_posts JOIN phpbb_users ON phpbb_posts.poster_id = phpbb_users.poster_id

Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#6 Sware

Sware
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 03 July 2006 - 10:14 AM

How do I add another join onto that
SELECT phpbb_posts.poster_id, phpbb_users.username FROM phpbb_posts JOIN phpbb_users ON phpbb_posts.poster_id = phpbb_users.poster_id (+ ANOTHER JOIN)

or can you not do that?

#7 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 03 July 2006 - 03:45 PM

Simply add another JOIN newTable ON ( condition).
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users