ugrás a tartalomhoz

mysql LEFT JOIN nem megy 5.x-en

paal · 2006. Már. 29. (Sze), 10.01
Üdv,

A következő lekérdezés nem fut le MySQL 5.0.18-Debian_9-log szerveren:
  1. SELECT SUM( catch.weight ) AS weight, team.name AS team_NAME, team.id AS team_ID, country.country_title AS country_NAME, ct.sector_id AS sector_ID, COUNT( catch.weight ) AS darabszam  
  2. FROM carp_team team, carp_contest_team ct, carp_country country  
  3. LEFT JOIN carp_catch catch ON catch.team_id = team.id  
  4. AND catch.contest_id = '3'  
  5. WHERE team.id = ct.team_id  
  6. AND ct.contest_id = '3'  
  7. AND team.country_id = country.country_id  
  8. GROUP BY team.id  
  9. ORDER BY 1 DESC  
A hibaüzenet a következő:
#1054 - A(z) 'team.id' oszlop ervenytelen 'on clause'-ben


??

A saját gépemen MySQL 4.0.24-nt fut, ott hiba nélkül megcsinálja. Mi lehet a gond?
Először arra gondoltam, hogy az 5-ös már nem enged "id" nevű táblát, de ha átjavítottam pl. team_id-nak, akkor is u.ez volt a hiba (értelem szerűen tam.team_id-val).

Nagyon köszi!
Üdv, Pali
 
1

ON catch.team_id = team.id

Poetro · 2006. Már. 29. (Sze), 10.15
  1. ON catch.team_id = carp_team.id  
2

Szigorúbb kifejezések

Török Gábor · 2006. Már. 29. (Sze), 10.20
A Google-t böngészve többen is találkoztak már ezzel a problémával. A How to make Joomla! MySQL 5 compatible cikkből idézbe:
The source for this error is that MySQL 5.0 has a more strict implementation of the SQL:2003 standard. Therefore the less strict SQL statements fail.
A megoldás nyitja elvileg abban rejlik, hogy a FROM és ON paramétereit zárójelezni kell, ahogy az írásban illusztrálják is.
3

Így jó lett:

paal · 2006. Már. 29. (Sze), 12.41
  1. SELECT   
  2.     DISTINCT(team.id),  
  3.     SUM(catch.weight) as weight,   
  4.     team.name as team_NAME,   
  5.     team.id as team_ID,   
  6.     country.country_title as country_NAME,   
  7.     ct.sector_id as sector_ID,   
  8.     COUNT(catch.weight) as darabszam  
  9.       
  10. FROM   
  11.     (carp_team team,   
  12.     carp_contest_team ct,   
  13.     carp_country country )  
  14.       
  15. LEFT JOIN   
  16.     carp_catch catch ON (catch.team_id=team.id AND   
  17.     catch.contest_id='3')  
  18.       
  19. WHERE   
  20.     team.id=ct.team_id AND   
  21.     ct.contest_id='3' AND   
  22.     team.country_id=country.country_id   
  23.       
  24. GROUP BY   
  25.     team.id  
  26.       
  27. ORDER BY 1 DESC