Top "Case" questions

In SQL, the CASE expression evaluates a list of conditions, returning the result for the first condition which evaluates to true.

How do I perform an IF...THEN in an SQL SELECT?

How do I perform an IF...THEN in an SQL SELECT statement? For example: SELECT IF(Obsolete = 'N' OR InStock = …

sql sql-server tsql if-statement case
OR is not supported with CASE Statement in SQL Server

The OR operator in the WHEN clause of a CASE statement is not supported. How can I do this? CASE …

sql sql-server tsql case case-when
"CASE" statement within "WHERE" clause in SQL Server 2008

I am working with a query which contains "CASE" statement within "WHERE" clause. But SQL Server 2008 is giving some errors …

sql sql-server case
Case in Select Statement

I have an SQL statement that has a CASE from SELECT and I just can't get it right. Can you …

sql sql-server case
SQL Switch/Case in 'where' clause

I tried searching around, but I couldn't find anything that would help me out. I'm trying to do this in …

sql switch-statement case
Can I use CASE statement in a JOIN condition?

The following image is a part of Microsoft SQL Server 2008 R2 System Views. From the image we can see that …

sql sql-server join case
MySQL select statement with CASE or IF ELSEIF? Not sure how to get the result

I have a two tables. One has manufacturer information and includes the regions where they can sell. The other has …

mysql select case
T-SQL: Using a CASE in an UPDATE statement to update certain columns depending on a condition

I am wondering if this is possible at all. I want to update column x if a condition is true, …

sql sql-update case
How to use a switch case 'or' in PHP

Is there a way of using an 'OR' operator or equivalent in a PHP switch? For example, something like this: …

php switch-statement case
SQL Server: converting UniqueIdentifier to string in a case statement

We have a log table that has a message column that sometimes has an exception stack trace. I have some …

sql-server guid case