FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Mysql Max not max





comp615
So I'm trying to select the maximum key from a HEAP table using:
SELECT MAX(`meetingid`) FROM `tempmeetings`

When I run this in mysql admin it returns the correct 493, but in php it comes out with 265. From what I can tell its decided to pick the min. I cannot for the life of me figure it out. Any ideas?
Stubru Freak
comp615 wrote:
So I'm trying to select the maximum key from a HEAP table using:
SELECT MAX(`meetingid`) FROM `tempmeetings`

When I run this in mysql admin it returns the correct 493, but in php it comes out with 265. From what I can tell its decided to pick the min. I cannot for the life of me figure it out. Any ideas?


Maybe post your php, it's very likely that you made a mistake there
comp615
Code:
$curr = mysql_query("SELECT * FROM `meetings`");
mysql_query("
DROP TABLE IF EXISTS `tempmeetings`;
CREATE TABLE `test`.`tempmeetings` (
  `meetingid` INTEGER UNSIGNED NOT NULL DEFAULT 0,
  `teachid` INTEGER UNSIGNED NOT NULL DEFAULT 0,
  `userid` INTEGER UNSIGNED NOT NULL DEFAULT 0,
  `timeid` INTEGER UNSIGNED NOT NULL DEFAULT 0,
  PRIMARY KEY(`meetingid`)
)
TYPE = MEMORY;");
while($currow = mysql_fetch_array($curr)) {
   extract($currow);
   doquery("INSERT INTO `tempmeetings` (meetingid,teachid,userid,timeid) VALUES ('$meetingid','$teachid','$userid','$timeid')");
}
$max = mysql_query("SELECT MAX(`meetingid`) FROM `tempmeetings`");
BlackSkad
What does it return without those ``?
Code:
SELECT MAX(meetingid) FROM `tempmeetings`
comp615
Ok I got it...the `` denotes a table or column, but the problem was that it wasn't actually deleting the table and redoing it. So it faked me out thinking that the max was wrong when actually the first set of inserts was wrong lol. Jeez thanks for the help neways! Razz
Related topics
MySQL DB Limits?
Mysql 5.0 and its limitation
PHP.ini and MYSQL databases
MySql -Connecting problems
mysql connection question
php admin and mysql admin console
Mysql And PHP HELP PLZ
Question about MySQL!
Do you use a CMS script?
PHP, MySQL...
PHP Book (Php and Mysql for Dynamic Web Sites)
few mysql questions
E-Cards with PHP & MySQL
HTTP AUTH with PHP and mySQL
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.