macromedia.coldfusion.getting_started
[Top] [All Lists]

Re: SQL question

Subject: Re: SQL question
From: "paross1"
Date: Wed, 30 Jan 2008 20:38:16 +0000 UTC
Newsgroups: macromedia.coldfusion.getting_started

[Q]I always understood that it is best to do everything in the sql.[/Q] Not 
necessarily. Also, nothing is ever "returned" from the WHERE clause of a query, 
only the SELECT. If you have a small set of posible values that will be 
matching in your query, you may be able to use a CASE statement in your SELECT, 
but that can get real nasty, especially as you add values to your Referer 
table, since that would require you to modify your query, which is NOT a 
desireable circumstance.

 Something like this, perhaps.

 SELECT 
  CASE 
        WHEN referer LIKE '%google.it%' THEN 'Google Italy'
        WHEN referer LIKE '%google'% THEN 'Google'
        WHEN referer LIKE '%msn%' OR referer LIKE '%live.com%' THEN 'MSN Live'
        WHEN referer LIKE '%yahoo%' THEN 'Yahoo'
        ELSE 'Other search engine'
  END AS new_referer
 FROM   clientinfo
 WHERE  whatever

 Phil




<Prev in Thread] Current Thread [Next in Thread>