Hello folks, My problem is that I am trying to get the 'maximum id' value from a table doing a Select and it seems it returns an "Empty set" e.g. Select field1 From table Where id = 'MAX(id)'; Now, if I do a Select statement e.g. Select MAX(id) From table; I get a value which is id=3. Did i define my table in a wrong way? Is there an easier way that I can retrieve the maximum 'id' from my table? Please advice. Thank you
well.. i think in the first query the "'" around the MAX(id) makes it a string compare rather than number compare..
try..
Select field1 From table login order by id desc limit 1;
this should works.. but could be better ways out there 😉
cheers
Is this mysql you're talking about? In that case, kuen's suggestion is the best way. Other solutions involve sub-selects, which mysql doesn't do (yet?)