mySQL where clause with alternative -
i have mysql query should return row incase found value, otherwise should use default value: mean, try find specific language return row, if language not found, query should use default specific language variable. (inside php code) eg. $language=fr , query should return fr language row otherwise, should return default en language row
select * my_table lang="$language"
i want return row of en language default row in case fr language (or other language) not found. how can this?
you can use case
, order by
select * table lang = case when lang = 'fr' 'fr' else 'en' end order lang = 'fr' desc limit 1
Comments
Post a Comment