bins
----
id min max
1 1 20
2 21 40
3 41 60
pictures
--------
id
3
11
59
Basically, I want to select the highest image identifier, and then select from the bin table the bin identifier that it matches. For example, for picture.id = 59 (highest), I want bins.id = 3. Can someone help me with this request? Sort of
SELECT bins.id AS id
FROM bins
JOIN pictures.id
ON bins.min < MAX(pictures.id)
AND bins.max > MAX(pictures.id)
doesn't seem to work. Thank!
source
share