I have a query which is working in MYSQL 4.1.x and 5.0.x but I want to convert it so it can work also in 4.0.15 (don't ask why ). Here is the query:

SELECT DISTINCT
mnr1, stf1, wRoleGroupStf.RoleID, wRoleGroupStf.GroupID
FROM ( SELECT DISTINCT mnr as mnr1, MAX(stf) AS stf1 FROM m1_Stamm2
WHERE (stf <> 'X') GROUP BY mnr1 ) AS TEMP
INNER JOIN wRoleGroupStf ON
(wRoleGroupStf.StfCode = TEMP.stf1)

The problem is that 4.0.x doesn't support SELECT after FROM

please help