see 12.2 Control Flow functions of MySQL manual

select name, if(adopted=0,'N','Y') from animal;


> -----Original Message-----
> From: Sue Cram [mailto:[EMAIL PROTECTED]
> Sent: Monday, February 07, 2005 2:58 AM
> To: mysql@lists.mysql.com
> Subject: How do I Put a 'Literal' Value in a Report Column?
> 
> 
> This is a pretty basic question, but I'm learning SQL from a 
> book and it's very very frustrating!   
> 
> I'm writing a report listing animals from our shelter and 
> whether they have been adopted.  I am selecting the animal 
> name field and a field called 'adopted' from a table called 
> 'animal'.  The values in 'adopted' are either:  1 (meaning 
> yes, this animal was adopted) or 0 (no, this animal has not 
> been adopted). 
>  
> So far I:
> "SELECT Name, Adopted FROM animal".  This prints a column of 
> animal names and a column labeled "Adopted" with row after 
> row of 0's and 1's.  I want my output report to say 'Y' if 
> 'adopted' = 1 or 'N' if adopted = 0.  
> 
> I've spent all day studying "Insert Into", "Update Where", 
> "If... Then", looking at SQL manuals (so far I've studied 3 
> of them), and trying to find an example in existing code.  I 
> get syntax errors for everything I try.  This is a very 
> simple thing that's done all the time -- but I can't figure 
> out how in SQL.  
> 
> Can someone help me?
> Thanks,
> Sue
> 
 
Attention:
Any views expressed in this message are those of the individual sender, except 
where the message states otherwise and the sender is authorized to state them 
to be the views of any such entity. The information contained in this message 
and or attachments is intended only for the person or entity to which it is 
addressed and may contain confidential and/or privileged material.  If you 
received this in error, please contact the sender and delete the material from 
any system and destroy any copies.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to