Mysqlselect语句设置默认值_MySQL
程序员文章站
2024-02-16 17:18:58
...
1.在没有设置默认值的情况下:
SELECT userinfo.id, user_name, role, adm_regionid, region_name , create_timeFROM userinfoLEFT JOIN region ON userinfo.adm_regionid = region.id结果:
设置显示默认值:
SELECT userinfo.id, user_name, role, adm_regionid, IFNULL(region_name,0) as region_name, create_timeFROM userinfoLEFT JOIN region ON userinfo.adm_regionid = region.id即:如果region_name一列的值为空,则显示为0,结果为:
上一篇: 从数据库管理下手 多手段提升网站安全