1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

mySQL LEFT join

Discussion in 'HTML, Graphics & Programming' started by Gman, 31 May 2006.

  1. Gman


    Joined: 18 Oct 2002

    Posts: 4,619

    Got a slight problem with a left join in mySQL, The codes below.
    This works perfectly in mySQL 3.whatever or 4.whatever but on my localhost u've just put mySQL version 5 and its not liking the LEFT join park of the code any ideas why??

    Heres the error: #1054 - Unknown column 'fixtures.away_team_id' in 'on clause'

    "SELECT fixtures.fixture_id, 
    	 teams.team_name AS home_team, 
    	 awayTeam.team_name AS away_team, 
    	  FROM fixtures, teams
    	  LEFT JOIN teams AS awayTeam ON fixtures.away_team_id = awayTeam.team_id
    	  WHERE fixtures.home_team_id = teams.team_id
    	  AND fixtures.fixture_id = $id"
  2. Beansprout

    Man of Honour

    Joined: 31 Jan 2004

    Posts: 16,313

    Location: Plymouth

  3. Gman


    Joined: 18 Oct 2002

    Posts: 4,619

    thanks mate,
    had a look in the Joins secition here http://dev.mysql.com/doc/refman/5.0/en/join.html but still non the wiser. Is it me or are the help pages on the mySQL site a touch on the pants side.


    Sorted: seems that you now have to wrap your tables in the from clause with parentheses. ummmm

    thanks again mate for pointing me in the right direction
    Last edited: 31 May 2006