quick mysql question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ryany
    Member
    • Nov 2000
    • 95

    quick mysql question

    I need to retrieve the biggest number from a mysql database.
    Say I need to retrieve the biggest $catergory_id and display it.

    How would the $sql line be like? 'SELECT * from catagories WHERE ??'

    Hope you get what i mean .
    Need help quickkk thanks
  • ryany
    Member
    • Nov 2000
    • 95

    #2
    *bump*

    Comment

    • Wayne Luke
      vBulletin Technical Support Lead
      • Aug 2000
      • 73981

      #3
      select MAX(field) from table
      Translations provided by Google.

      Wayne Luke
      The Rabid Badger - a vBulletin Cloud demonstration site.
      vBulletin 5 API

      Comment

      • ryany
        Member
        • Nov 2000
        • 95

        #4
        can the field be a primary key?

        Comment

        • Wayne Luke
          vBulletin Technical Support Lead
          • Aug 2000
          • 73981

          #5
          Sure.. It should work on all non-text (char, varchar, text, blob) fields.

          select MAX(userid) from user

          would return the highest userid used so far.
          Translations provided by Google.

          Wayne Luke
          The Rabid Badger - a vBulletin Cloud demonstration site.
          vBulletin 5 API

          Comment

          • ryany
            Member
            • Nov 2000
            • 95

            #6
            ah ! it worked! thanks =D

            Comment

            widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
            Working...