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 picture Id and then select from the bin table the bin id it matches. For example, for a pictures.id = 59 (highest), I want bins.id = 3. Can anyone help me with such a query? Something like
SELECT bins.id AS id
FROM bins
JOIN pictures.id
ON bins.min < MAX(pictures.id)
AND bins.max > MAX(pictures.id)
doesn't appear to work. Thanks!
SELECT id
FROM bins
WHERE min < (Select Max(id) from Pictures)
AND max > (Select Max(id) from Pictures)
Hope it helps
Max
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With