Subquery that works in 4.1 Breaks in 5.1

I’m upgrading the MySQL on my production server and I found a couple queries that are breaking on the new version (5.1.58).

Here’s the stripped down version of the query:

SELECT *
  FROM s01_Products currentprod_prod
INNER
  JOIN s01_MUS_Categories currentprod_cat
    ON currentprod_cat.cat_id = (
        SELECT t_cat.cat_id
          FROM s01_MUS_Categories t_cat
         INNER
          JOIN s01_MUS_CategoriesXProducts t_catxprod
            ON t_catxprod.cat_id = t_cat.cat_id
           AND t_catxprod.prod_id = currentprod_prod.id
         WHERE t_cat.active = 1
         ORDER
            BY IF(t_cat.parent_id > 0, 0, 1)
             , parent_id
             , cat_id
         LIMIT 1
       )
   AND currentprod_cat.active = 1
 WHERE currentprod_prod.code = 'BLUE-WIDGET'

In this state, the query is just looking for the first parent category it can find for the current product “BLUE-WIDGET”.

The error I receive on the new server is:

Unknown column ‘currentprod_prod.id’ in ‘on clause’

This query, copied and pasted to the new server, returns exactly one row, as it should.

I’m not at all familiar with 5.X, so I don’t know what bad habit I’ve picked up from 4.1. Can someone point it out?

I don’t understand why, but if I move the “AND t_catxprod.prod_id = currentprod_prod.id” line from the JOIN condition to the WHERE condition, the SQL works:

SELECT *
  FROM s01_Products currentprod_prod
INNER
  JOIN s01_MUS_Categories currentprod_cat
    ON currentprod_cat.cat_id = (
        SELECT t_cat.cat_id
          FROM s01_MUS_Categories t_cat
         INNER
          JOIN s01_MUS_CategoriesXProducts t_catxprod
            ON t_catxprod.cat_id = t_cat.cat_id
         WHERE t_cat.active = 1
           AND t_catxprod.prod_id = currentprod_prod.id
         ORDER
            BY IF(t_cat.parent_id > 0, 0, 1)
             , parent_id
             , cat_id
         LIMIT 1
       )
   AND currentprod_cat.active = 1
 WHERE currentprod_prod.code = 'BLUE-WIDGET'

Still up for an explanation as to why this broke.