List:General Discussion« Previous MessageNext Message »
From:Scott Turnbull Date:December 4 2003 3:23pm
Subject:WHERE with CASE colums?
View as plain text  
I have a table called 'Journal_Info' containing titles of various journals

When searching and listing them I want to remove any preceeding 'The ', 'An ', or 'A '
that occurs in the title and I also want to be able to search it.  The case statement as
follows seems to work fine:

SELECT 
CASE 
WHEN title LIKE  'The %' THEN RIGHT( title, length( title )  -4  ) 
WHEN title LIKE  'A %' THEN RIGHT( title, length( title )  -2  ) 
WHEN title LIKE  'An %' THEN RIGHT( title, length( title )  -3  ) 
ELSE title
END  AS modtitle
FROM Journal_Info

But if I try a WHERE clause using the columns AS title I get an error.

Can anyone help me figure out how to search the CASEed column?

Thanks in advance for any help.

Scott
Thread
WHERE with CASE colums?Scott Turnbull4 Dec
  • Re: WHERE with CASE colums?Martijn Tonies4 Dec
  • Re: WHERE with CASE colums?Yves Goergen4 Dec