MySQL LEFT JOIN error

后端 未结 3 1785
暗喜
暗喜 2021-01-22 06:39

I\'ve got some SQL that used to work with an older MySQL version, but after upgrading to a newer MySQL 5 version, I\'m getting an error. Here\'s the SQL:

SELECT          


        
3条回答
  •  梦毁少年i
    2021-01-22 07:03

    The way you have written the query, the compiler thinks you want to left join portfolio to types, so it complains that your on clause references the projects table.

    Try this ANSI-style version:

    SELECT * 
    FROM projects p
    inner join types t on p.projectType = t.typeID AND t.typeID = #URL.a#
    LEFT JOIN portfolio pf ON pf.pfProjectID = p.projectID 
    ORDER BY t.typeSort, p.projectPriority
    

提交回复
热议问题