Makes sense. Thanks for the help! Rik Forgo JIST3 Army Test, Training and Technology Integration Office (T3I) Diverse Technologies Corp. (c) 443.463.8571 (h) 410.859.8474
> -----Original Message----- > From: Jon Wagoner [mailto:[EMAIL PROTECTED] > Sent: Monday, February 24, 2003 4:51 PM > To: Richard Forgo; MySQL Mailing List > Subject: RE: case expression > > Consider the CASE statement to be a function, that can only return values. > Aliases would go outside the CASE STATEMENT, as follows: > > SELECT > CASE > WHEN CHARACTER_LENGTH(system) > 65 > THEN > CONCAT(LEFT(system, 60), " ...") > ELSE > system > END AS system, > wsh_year, > id > FROM wsh > > -----Original Message----- > From: Richard Forgo [mailto:[EMAIL PROTECTED] > Sent: Monday, February 24, 2003 3:44 PM > To: Jon Wagoner; 'MySQL Mailing List' > Subject: RE: case expression > > > Thanks, that works fine. If I wanted to create an alias for the column, > how would I do that? The first select statement (before the Else) is > the current column name. > > When I add 'AS system' to the end of the string, it fails. > > Ex. > > SELECT > CASE > WHEN CHARACTER_LENGTH(system) > 65 > THEN > CONCAT(LEFT(system, 60), " ...") > ELSE > system AS system > END, > wsh_year, > id > FROM wsh > > Rik Forgo > JIST3 > Army Test, Training and Technology Integration Office (T3I) > Diverse Technologies Corp. > (c) 443.463.8571 > (h) 410.859.8474 > > > > -----Original Message----- > > From: Jon Wagoner [mailto:[EMAIL PROTECTED] > > Sent: Monday, February 24, 2003 4:34 PM > > To: Richard Forgo; MySQL Mailing List > > Subject: RE: case expression > > > > Put the other fields after the CASE statement: > > > > SELECT > > CASE > > WHEN CHARACTER_LENGTH(system) > 65 > > THEN > > CONCAT(LEFT(system, 60), " ...") > > ELSE > > system > > END, > > wsh_year, > > id > > FROM wsh > > > > The CASE statement just returns 1 field. > --------------------------------------------------------------------- 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