Jump to content


Photo

Calling data from 3 MySQL tables


  • Please log in to reply
2 replies to this topic

#1 Mr Chris

Mr Chris
  • Members
  • PipPipPip
  • Advanced Member
  • 336 posts

Posted 14 September 2006 - 02:06 PM

Hi,

I'm trying in PHP to call out an SQL statement to enter data from 3 tables, now i've done it with two:


Select * FROM `cms_competitions`
LEFT OUTER JOIN cms_competition_pics
ON cms_competitions.competition_id = cms_competition_pics.competition_id 
WHERE cms_competitions.competition_id=".$_GET['competition_id'],$link);


But how do include another table ie cms_competition_logos?

I understood a two table join, but a three i'm confused on?

Thanks

Chris

#2 gerkintrigg

gerkintrigg
  • Members
  • PipPipPip
  • Magician
  • 828 posts
  • LocationBristol, UK
  • Age:37

Posted 14 September 2006 - 05:48 PM

you'd normally do it with commas... FROM member, item, category....
but to do it with a left join, I'm not sure. You might need to use () to encapulate each LEFT OUTER JOIN command and then add a comma and another () to encapsulate another.

Try writing what you want to do in plain english (or your mother language if different) and translate it into pseudo code (semi-logical PHP). That might help.
Neil Trigger - http://www.ghostlypublishing.co.uk - Ghostly Publishing - Children's Fantasy Books

#3 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 14 September 2006 - 06:42 PM

It's alot easier, and in my opinion a lot easier to mantain, to just do 1 db call, then the other db call after that.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users