I have this piece of MySQL code that is driving me mad:
UPDATE Sells SET number = '$number'
WHERE id_student = '$id_student' AND id_book = '$id_book'
AND Hour = (SELECT MAX(Hour) FROM Sells WHERE id_student = '$id_student')
It doesn't blow up but it doesn't do what it is supposed to do either. If I take out the last part (the Hour clause) it works as it should, but when I add it as in the code above, it just does nothing (as if there where no Hours in the table, which is false). Hour type is INT.
Any ideas on how could I get the last clause working? Somehow it must be bad-written, but I can't see where.