> -----Original Message----- > From: Zak Greant [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 13, 2003 10:38 AM > To: [EMAIL PROTECTED] > Subject: Re: MySQL Feature > > > On Thu, Feb 13, 2003 at 09:57:06AM -0500, Luc Foisy wrote: > > > > I don't think it is possible at the moment, and pretty sure > its not standard SQL but it would still be neat to have > > > > SELECT aField, COLUMN_IF( some_expression, 'afield2' AS > 'aColumn' ) FROM aTable > > > > So in this example, if the expression was true, include > that column in the result set, otherwise don't > > Sure this can be handled outside MySQL and just change the > query on condition, just thought it would be nice > > You can use a WHERE clause to get an effect like this. > > Something like: > > SELECT CASE expression > WHEN 'value' > THEN column > ... > ELSE 'default result' > END > FROM Table;
BUT SELECT Data, CASE WHEN 0 != 0 THEN 'Something' END FROM table will return two columns, "Data" and "CASE WHEN 0 != 0 THEN 'Something' END". It would be better if I could do.. SELECT Data, CASE WHEN 0 != 0 THEN 'Something' AS 'A Column' END FROM table and the result set would only contain one column, "Data" I am sure people could find a use for it... --------------------------------------------------------------------- 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