When creating a view in phpmyadmin on yahoo business I need to know the corrct syntax to return text. Below are two examples of an If statement and a case statement that return an Integer. Both of these views work correctly. There are also three examples of an If statement to return text and three examples of case statements to return text. None of these six examples work correctly even when using using single quotes, double qoutes or no quotes at all. Please review all of the below examples and let me know what is happening that the select statement changes.
SELECT If(Month(Now())=2,555,999)
works correctly
SELECT case Month(now()) when 2 then 555 else 999 end
works correctly
SELECT If(Month(Now())=2,'Feb','Oth')
changes the select statement
to:
SELECT If(Month(Now())=2,\'Feb\',\'Oth\')
and gives error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\'Feb\',\'Oth\')' at line 5
SELECT If(Month(Now())=2,"Feb","Oth")
changes the select statement to:
SELECT If(Month(Now())=2,\"Feb\",\"Oth\")
and gives error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\"Feb\",\"Oth\")' at line 5
SELECT If(Month(Now())=2,Feb,Oth)
gives below error:
#1054 - Unknown column 'Feb' in 'field list'
SELECT case Month(now()) when 2 then 'Feb' else 'Other' end
changes the
select statement to:
SELECT case Month(now()) when 2 then \'Feb\' else \'Other\' end
and gives error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\'Feb\' else \'Other\' end' at line 5
SELECT case Month(now()) when 2 then "Feb" else "Other" end
changes the select statement to:
SELECT case Month(now()) when 2 then \"Feb\" else \"Other\" end
and gives below error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\"Feb\" else \"Other\" end' at line 5
SELECT case Month(now()) when 2 then Feb else Other end
gives below error:
#1054 - Unknown
column 'Feb' in 'field list'