PDA

View Full Version : stupid mysql question


amykhar
05-01-2003, 03:06 AM
I know it's easy and I think the word I am looking for is MAX, but how do I get the maximium value of a column in a table? For example, the highest userid in the user table?

I am bone tired and too wiped to go looking for it tonight.

The way I was doing it seems really slow when I look at debug. I was selecting 1 ordering by userid desc.

Thanks in advance. I owe somebody a cheerful answer to one stupid question :D

Amy

Erwin
05-01-2003, 03:29 AM
Your way ordering in desc would work.

This would also work:


SELECT MAX(userid) FROM user;


Much easier.

amykhar
05-01-2003, 01:50 PM
Thank you Erwin. Yes, I know my way worked, but when I ran the board in debug mode I saw that it was taking a long time to run that query. I am trying to optimize a bit and thought I would try this. Thank you :)

Amy

amykhar
05-01-2003, 02:01 PM
OMG I can't believe the difference changing those two queries made. Before, my forumhome took 1.4 seconds to load on average. I upgraded to mysql 4 and got it down to between .89 and 1.2 seconds.

Changing two queries to get the MAX correctly instead of my way means forumhome now loads in .30 seconds!

Amy