Home > Database > Mysql Tutorial > Mysqlselect语句设置默认值_MySQL

Mysqlselect语句设置默认值_MySQL

WBOY
Release: 2016-06-01 13:13:32
Original
1293 people have browsed it

1.在没有设置默认值的情况下:

SELECT userinfo.id, user_name, role, adm_regionid, region_name , create_timeFROM userinfoLEFT JOIN region ON userinfo.adm_regionid = region.id
Copy after login
结果:

/

设置显示默认值:

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
Copy after login
即:如果region_name一列的值为空,则显示为0,结果为:

/

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template