finding the largest numbers

Thread Solved

Join Date: Mar 2008
Posts: 43
Reputation: severman is an unknown quantity at this point 
Solved Threads: 0
severman severman is offline Offline
Light Poster

finding the largest numbers

 
0
  #1
Oct 2nd, 2009
hi all
could any 1 help me out.
im trying to find the biggest id number in a db.
the problem is that the "ID" column is saved as "TEXT"(its important to me).
the language im using is PHP.
10x!

tried to use this but it didnt work
  1. $resultt = mysql_query("SELECT MAX(id) FROM object" , $conn);
  2. $row = mysql_fetch_array($resultt);
  3. $num=$row[maxnum];
[/code]
Last edited by severman; Oct 2nd, 2009 at 4:27 pm.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 1,403
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 225
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: finding the largest numbers

 
2
  #2
Oct 2nd, 2009
A) Why is your ID field TEXT?
B)
  1. SELECT MAX(CAST(id AS DECIMAL)) as id FROM object
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 43
Reputation: severman is an unknown quantity at this point 
Solved Threads: 0
severman severman is offline Offline
Light Poster

Re: finding the largest numbers

 
0
  #3
Oct 2nd, 2009
thanx man
i used it as a text because when i started i didnt want to give auto id, and its easier to work on string in php...
but now i do and instead of changing 20 pages i wanted to change the command...
anyway 10x!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC