Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

assign value to variable based on a field value...

Status
Not open for further replies.

MizzGail

Technical User
Dec 4, 2002
11
US
I have a query where I am select field 1, field 2. Based on the value of feild 2 I would like to be able to output another field with a value, but this field is not a field on my table. (varfld 1)
When field 2 = "1" I want varfld 1 = "cookie"
When field 2 = "2" I want varfld 1 = "donut"

How do I do this?
 
What is your database?

good luck,
nicsin

A boy is smoking and leaving smoke rings into the air.

His girlfriend gets irritated with the smoke and says to her lover:
"Can't you see the warning written on the cigarettes packet, smoking is bad to
your health!"

The boy replies back:
"Darling, I am a programmer. We don't worry about warnin
 
CASE field 2
WHEN "1" THEN "cookie"
WHEN "2" THEN "donut"
ELSE "any other value that you want"
END
AS field 2
 
Code:
select case when field2 = '1' then 'cookie'
            when field2 = '2' then 'donut' end, 
  <rest of columns> 
  from ogrish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top