Re: Get highest value of key most efficiently

From: Date: Mon, 02 Jul 2001 09:29:54 +0000
Subject: Re: Get highest value of key most efficiently
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-55806@lists.php.net to get a copy of this message
Hi, SELECT MAX(column_name) FROM table_name Though for what youre trying to do its better to use an autoincrementing field. That way the database will automaticly increment the key when you do an insert regards, wieger Kraa de Simon wrote: > > Hi, > > SQL newbie... > > What is the most efficient way to get the highest value of a key value using > the odbc_* functions/SQL syntax? > > E.g. if I have a table with key values 1,2,3...1567 I need the higest value: > 1567 so I can create a new record and assign key value 1568. > > I don't want to read the whole table... > > Met vriendelijke groet / With kind regards, > > ICL Nederland B.V. Simon de Kraa > e-Applications / Logistic Systems Systems Architect > Het Kwadrant 1 Tel. +31 346 598865 > Postbus 4000 Fax +31 346 562703 > 3600 KA MAARSSEN > The Netherlands > mailto:Simon.de.Kraa@icl.nl > > --- > > Microsoft Windows 2000 5.00.2195 SP 2, Progress 9.1b, Roundtable 9.1c > SCO UnixWare 7.1.1, Progress 9.1b > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net -- Wieger Uffink tel: +31 20 428 6868 fax: +31 20 470 6905 web: http://www.usmedia.nl

« previous php.general (#55806) next »