Results 1 to 3 of 3

Thread: Sql query question

  1. #1

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Sql query question

    Not sure if this is the right place to post this but here goes....

    I've got a field in my mysql db that contains both alpha and numeric values.

    I'm trying to find the highest numeric value but using the below returns an alpha value.

    Can I add a where clause so it only finds the max value of the numeric values in the field?

    PHP Code:
    SELECT MAX(MyField) AS MaxValue FROM MyTable 

  2. #2
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    354

    Re: Sql query question

    post an example of your data, the entire row would be nice. 6x6x6x6, 9999ABz? Max() should return the highest ASCII value. It depends on your data as to how you want to do this?

  3. #3
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Sql query question

    You can cast the data to a numeric type, but that will only work if the number is at the beginning of the string. Like suggested above, you need to post an example of the formatof your data.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width