mySQL where clause with alternative -


enter image description herei 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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -