I need to convert this PHP code into the MySQL query equivalent
$name = 'John Doe';
if($citizenship == 'o') {
if($country == 'US') {
$status = 'US-INTL';
}else{
$status = 'INTL';
}
} elseif {
$status = 'US'
}
I am having trouble with MySQL’s if-then statements, even after reading their very minimal documentation on it. I’ve tried different nesting techniques but they all fail because I don’t know the syntax. For example:
SELECT name, IF citizenship='US' THEN
IF country='US' THEN 'US-INTL' AS status
ELSEIF 'INTL' AS status
ELSE
'US' AS status
END IF
FROM people
MySQL should return something like
_________________
name | status
-----------------
John Doe | US-INTL
-----------------
or mysql-specific way: