I have a problem with MySQL at this moment.
I’m trying to determine the highest float value from my table like this:
SELECT `id`
FROM `LOTRESULTS`
WHERE
`value`= (SELECT MAX(value) FROM `LOTRESULTS`) AND
`lot_id` = 180
ORDER BY `id` DESC
LIMIT 1
This works whenever I choose let’s say id 180, but none of the other combinations work.
There are 3 entries with 180 as lot_id, and 2 occurences with 179 as lot_id, etc.
It just works randomly, it fails on most of the entries in the DB.
Am I doing something wrong? Should I change the datatype of the value column?
Thanks in advance guys!
p.s. I’ve also tried:
SELECT `id` FROM `LOTRESULTS` WHERE `value`= (SELECT MAX(value) FROM
`LOTRESULTS`) AND `lot_id` = 180
and
SELECT `id` FROM `LOTRESULTS` WHERE `value`= (SELECT MAX(value) AS
`value` FROM `LOTRESULTS`) AND `lot_id` = 180
with the same results…
You don’t really have to use sub-query, or JOIN,
a simple where + order + limit will do :-