Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 06-07-2009, 05:13 PM   #1 (permalink)
mugwumpr
Recruit
 
Join Date: May 2009
Posts: 12
mugwumpr is on a distinguished road
Unhappy Not unique table/alias: 'fd_collection'

I'm trying to join two tables (fd_eggs and fd_collection) so that I can use info from both, but I keep getting the error
Quote:
Not unique table/alias: 'fd_collection'
I've hunted around, but can't find anything that gives me a hint as to where the error is.

Here's the query:
PHP Code:
$query "SELECT fd_eggs.ID AS feid, fd_eggs.name AS fename, fd_collection.member_ID as memb
 FROM fd_eggs, fd_collection
 LEFT JOIN fd_collection
 ON fd_eggs.ID = fd_collection.egg_ID
 ORDER BY releasedate DESC"

Any advice greatly appreciated.

(gawd, i hate being this much of a n000b)
mugwumpr is offline   Reply With Quote
Old 06-07-2009, 07:58 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,706
sde is on a distinguished road
can you clarify your table names, and field names of those 2 tables? just the relevant fields will be fine.
__________________
Mike
sde is offline   Reply With Quote
Old 06-07-2009, 09:04 PM   #3 (permalink)
mugwumpr
Recruit
 
Join Date: May 2009
Posts: 12
mugwumpr is on a distinguished road
fd_eggs:
ID (primary)
name (unique)
releasedate

fd_collection:
egg_ID (fk to fd_eggs.ID)
member_ID (fd to fd_members.ID)
egg_name

fd_eggs holds all the info about the eggs (natch), and fd_collection is like an intermediary table that connects fd_eggs to the fd_members that own them.

Does that help?
mugwumpr is offline   Reply With Quote
Old 06-07-2009, 10:09 PM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,706
sde is on a distinguished road
change this
Code:
FROM fd_eggs, fd_collection
to this

Code:
FROM fd_eggs
also, you may want to get into the habbit of using INNER JOIN instead of left join for performance reasons. only use left join when you absolutely have to.
__________________
Mike
sde is offline   Reply With Quote
Old 06-08-2009, 05:57 AM   #5 (permalink)
mugwumpr
Recruit
 
Join Date: May 2009
Posts: 12
mugwumpr is on a distinguished road
Thank you again! It's working now.

I used LEFT JOIN here because, according to what I've read at least, it's the only thing that will pull all the info from fd_eggs even if there's no corresponding info in fd_collections. Will INNER JOIN do that too, or does it only pull rows where there's matching data?
mugwumpr is offline   Reply With Quote
Old 06-08-2009, 02:49 PM   #6 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,706
sde is on a distinguished road
left join is correct then. inner join will not include any records that don't share the join values.
__________________
Mike
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Table Problems Fragby HTML, XML, Javascript, AJAX 0 01-18-2009 10:20 AM
Keeping sessions unique when someone links with SESSID? Admin PHP 18 02-13-2005 10:44 AM
Re:Inserting and displaying Unique Statistics from users viewing my site, problem bearslife PHP 3 08-07-2004 08:58 AM
Table problems prendo HTML, XML, Javascript, AJAX 12 04-06-2003 06:38 AM
help me name a table sde Lounge 4 12-07-2002 01:50 PM


All times are GMT -8. The time now is 12:49 PM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting