On 27 Dec 2002, at 1:04, Peter D Bethke wrote: > My table "matchups" has columns for team1_id, team2_id, team1_score and > team2_score. > > I can write a simple calculation using the api I use (Lasso - similar in > function to php) and display the results programmatically in the html > output, not involving MySQL, but I wonder if I can use a function, or > something similar to get a new column "winner".
Something like this query maybe? SELECT team1_id, team2_id, team1_score, team2_score, CASE WHEN team1_score > team2_score THEN team1_id WHEN team1_score < team2_score THEN team2_id ELSE NULL END AS winner FROM matchups WHERE ... -- Keith C. Ivey <[EMAIL PROTECTED]> Tobacco Documents Online http://tobaccodocuments.org Phone 202-667-6653 --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php