Invalid Identifier SQL

前端 未结 1 1665
借酒劲吻你
借酒劲吻你 2020-12-12 04:50

So i have this:

SELECT p.plantnaam,o.levcode,o.offerteprijs
FROM plant p, offerte o
JOIN (SELECT plantcode , MIN(offerteprijs) AS offprijs 
      FROM offert         


        
1条回答
  •  佛祖请我去吃肉
    2020-12-12 05:07

    The problem is that you are mixing JOINs. You have both implicit and explicit joins. The explicit JOIN syntax with the ON clause has a higher precedence over the implicit join with the commas. As a result the alias for the plant and the offerte tables will not be available in the ON clause. Try using the same JOIN type throughout:

    SELECT p.plantnaam, o.levcode, o.offerteprijs
    FROM 
    (
      SELECT plantcode , MIN(offerteprijs) AS offprijs 
      FROM offerte
      GROUP BY plantcode
    ) s
    INNER JOIN plant p
       ON s.plantcode = p.plantcode
    INNER JOIN offerte o
       ON s.offprijs = o.offerteprijs
    ORDER BY p.plantnaam, l.levcode
    

    0 讨论(0)
提交回复
热议问题