Jump to content

Need Help with PHP Query


o0Loco0o

Recommended Posts

I have 3 tables, and what I am trying to do is get this to output

just the characters.name and appropriate guild.name for that character.

 

Table: characters

Columns: guid, name

 

Table: guild_member

Columns: guid, guildid

 

Table: guild

Columns: guildid, name

 

I have tried this query:

SELECT characters.name, guild.name
FROM characters, guild
WHERE guild_member.guid = characters.guid AND guild_member.guildid = guild.guildid

 

But it did not work... =(

 

Please Help!

 

Thank you in advance!

Link to comment
Share on other sites

Use explicit JOINs instead of the implicit ones you've used above. The explicit ones gives you more control, and considerably lessens the risk of getting a Cartesian product. Not to mention that they make it a whole lot easier to read what's actually going on. ;)

 

That said you do have a problem with your logic here, as you're only joining two of the three tables. Also, since this appears to be a many-to-many relation you might want to read up on how them. There are plenty of good guides online, so just search about until you find one. Mind the crappy ones though. :P

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.