sql 语句总结

一、查询结果字符拼接

SELECT t.*, CONCAT(IFNULL(d.device_num,‘‘),IFNULL(d1.device_num,‘‘)) AS deviceNum,d.device_name,pr.name AS provinceName,cr.name AS cityName,dr.name AS districtName  FROM simcard t
    LEFT JOIN emergency d ON t.device_id = d.id
    LEFT JOIN battery d1 ON t.device_id = d1.id
    LEFT JOIN region pr ON pr.id=t.province_id
    LEFT JOIN region cr ON cr.id= t.city_id
    LEFT JOIN region dr ON dr.id=t.district_id
   

 

sql 语句总结

上一篇:sql server日志查错


下一篇:MySQL:行锁、表锁、乐观锁、悲观锁、读锁、写锁