Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

SQL Syntax

Options
  • 02-11-2003 2:12pm
    #1
    Registered Users Posts: 2,281 ✭✭✭


    Hi there,

    I am trying to do the following in mysql
    var = MAX (var, othervar);
    
    or  another way:
    
    var = (othervar > var) ? othervar : var;
    
    

    So far i have my statement like this:
    $query = "UPDATE players SET best_streak=MAX(current_streak, best_streak) WHERE user_id=$winner LIMIT 1";
    


    That is not how MAX is used in mysql, i know that.

    Does anyone know how to do it?


Comments

  • Registered Users Posts: 2,281 ✭✭✭DeadBankClerk


    Got it sorted with GREATEST () thanks to ecksor!


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    For future reference, and even more flexibility, the CASE statement should be worth getting to know.

    jc


Advertisement