locate
1、可以用于判断某一个字段是否以什么来开头 locate‘开头的字符串’,列名称)
2、返回字符串substr中第一次出现子字符串的位置 str。LOCATE(substr,str)
3、返回字符串substr中第一个出现子 字符串的 str位置,从位置开始 pos。0 如果substr不在,则 返回str。返回 NULL如果substr 或者str是NULL。LOCATE(substr,str,pos)
if
if函数的使用(sql语句也支持多层嵌套的使用,这个类似于三木运算符)
select
if(IFNULL(county,'')='',if(IFNULL(city,'')='',province,city),county) as county,
name,id
from hospital
where flag = '0'