Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 9th, 2004, 03:53 PM
Authorized User
 
Join Date: Sep 2003
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default getting the greatest number

I have a db with a field called QuoteID in the table quotes. I need to get the greatest value for that field. In mysql I can use select max(QuoteID) but in php I am having problems with this. I need to increment this number by one and use it in another part of the script.
Any and all help is appreciated.

 
Old August 9th, 2004, 04:24 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

SELECT * FROM table ORDER BY QuoteID DESC LIMIT 1

HTH,

Snib

<><
 
Old August 10th, 2004, 05:53 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 256
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That'll work, Snib, but why wasn't SELECT MAX(QuoteID) working?
 
Old August 10th, 2004, 08:36 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

I don't think MySQL supports MAX. Correct me if I'm wrong :-)

Snib

<><
 
Old August 10th, 2004, 11:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 256
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, I won't correct you, since the copy you have may not do so, but the copy I've got infront of me does. It's MySQL 4.01 running on Redhat.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Validation For Phone Number and Mobile Number dhruthi.ram99 Javascript How-To 12 October 30th, 2011 07:24 AM
get the DDR number yanis97 J2EE 0 August 23rd, 2005 11:17 AM
number pixel Perseus Beginning VB 6 1 August 11th, 2005 05:08 PM
number? crmpicco Classic ASP Basics 2 June 10th, 2005 05:14 AM
Retreive latest and greatest record alexvgs Oracle 3 April 25th, 2005 09:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.