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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can LIKE be used inside a CASE stmt? 1

Status
Not open for further replies.

Sheffield

Programmer
Joined
Jun 1, 2001
Messages
180
Location
US
I don't think so, and I feel stupid for asking, but I need confirmation.

Consider the following code where I would like to control the output of many different spellings of 'Pittsburgh' in different fields:

Code:
SELECT Name, Addr1, Addr2,
   CASE City
     WHEN
Code:
like 'Pitt%'
Code:
 THEN ("Pittsburgh")
        ELSE (City) END as "City",
       State, Zip
FROM tblTableA

I receive syntax errors using this code. Is there a method by which I can achieve the same result, without detailing every possible spelling?
 
Sheffield,

You simply have a syntax error...

select
case
when city like 'pitt%' then
'Pittsburgh'
else
city
end
,state
,zip
from
tblTableA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top