943,946 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Marked Solved
  • Views: 796
  • MySQL RSS
Oct 2nd, 2009
0

finding the largest numbers

Expand Post »
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
MySQL Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
severman is offline Offline
70 posts
since Mar 2008
Oct 2nd, 2009
2

Re: finding the largest numbers

A) Why is your ID field TEXT?
B)
sql Syntax (Toggle Plain Text)
  1. SELECT MAX(CAST(id AS DECIMAL)) as id FROM object
Sponsor
Reputation Points: 520
Solved Threads: 268
Code Monkey
ShawnCplus is offline Offline
1,564 posts
since Apr 2005
Oct 2nd, 2009
0

Re: finding the largest numbers

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!
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
severman is offline Offline
70 posts
since Mar 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MySQL Forum Timeline: Mysql query
Next Thread in MySQL Forum Timeline: Compare and update products pricing columns





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC