4 messages in com.mysql.lists.mysqlRe: MAX(ID)| From | Sent On | Attachments |
|---|---|---|
| Oleg Timofeyev | 07 Mar 2000 15:57 | |
| Jonathan Stimmel | 07 Mar 2000 16:08 | |
| Oleg Timofeyev | 07 Mar 2000 16:26 | |
| Benjamin Pflugmann | 07 Mar 2000 21:30 |
| Subject: | Re: MAX(ID)![]() |
|---|---|
| From: | Benjamin Pflugmann (phil...@spin.de) |
| Date: | 03/07/2000 09:30:24 PM |
| List: | com.mysql.lists.mysql |
Hi.
Your problem is, that VARCHAR will be ordered aphabetically, not numerically, that is "999" is greater than "2000", since "9" is greater than "2".
If you have no compelling reason to have ID as VARCHAR, just do
ALTER TABLE table1 MODIFY ID INT NOT NULL
and everything should work as you expect. Don't forget that other fields have to be the same type as ID (i.e. INT) to use indexes in JOINs (at least in 3.22.x), so you should check all your tables.
If this is no option to you, you can use
SELECT MAX(ID+0) FROM table1
Be aware, that this will prevent the use of any index (i.e. do a full table scan) and will be a lot slower than if you correct your field types.
Bye,
Benjamin.
On Tue, Mar 07, 2000 at 04:27:05PM -0800, oleg...@2xdigi.com wrote:
Hi,
Here, I answered what I could. Could the problem be with the field because its not INT? if yes how can I change it without destroying all the records in the field?
It's hard to provide help without information: - what version of mysql are you using, and have you tried upgrading?
Version 3.22.25
- what is your table structure?
CREATE TABLE table1 ( ID varchar(14) NOT NULL, URL varchar(255), TITLE varchar(255), DESCRIPTION text, PRIMARY KEY (ID) );
- does isamchk report any errors on the table?
dont have access
- are you running the SELECT from mysql, or from another client?
telnet -> mysql monitor
Sincerely, Oleg Timofeyev 2xDiGi (818)476-0076 oleg...@2xdigi.com
--
--------------------------------------------------------------------- Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before posting. To request this thread, e-mail mysq...@lists.mysql.com
To unsubscribe, send a message to: <mysql-unsubscribe-philemon=spin...@lists.mysql.com>




