I want to convert below mysql query to sql query.I want to use If condition in sql server
SELECT
foodName,
IF( foodPrice>2000, 'Expensive', 'Cheap') as fpDesc,
discountPercent
FROM restaurant.foods;
if is MySQL proprietary, as you noticed. The standard way to do this is case
CASE WHEN foodPrice > 2000
THEN 'Expensive'
ELSE 'Cheap'
END
See also: http://modern-sql.com/feature/case
IIF()if u r working withsql-server 2012or+elsecaseexpression