I have a query like this:
SELECT m...., a...., r....
FROM 0_member AS m
LEFT JOIN 0_area AS a ON a.user_id = (SELECT user_id
FROM `0_area`
WHERE user_id = m.id
ORDER BY sec_id ASC LIMIT 1)
LEFT JOIN 0_rank as r ON a.rank_id = r.id
WHERE m.login_userid = '$username'
The idea is to get the first row from table 0_area and, therefore, try an internal join. However, it does not work as expected.
Between 0_area and 0_member, 0_member.id = 0_area.user_id. However, there are several lines 0_area.user_id, and I want the line to have the lowest sec_id value.
Any help please?
source
share