zoukankan      html  css  js  c++  java
  • mysql select column default value if is null

    mysql select column default value if is null

     SELECT
      `w`.`city`            AS `city`,
      `w`.`city_en`         AS `city_en`,
      `w`.`date_y`          AS `date_y`,
      `w`.`week`            AS `week`,
      `w`.`cityid`          AS `cityid`,
      `w`.`temp1`           AS `temp1`,
      `w`.`temp2`           AS `temp2`,
      `w`.`temp3`           AS `temp3`,
      `w`.`temp4`           AS `temp4`,
      `w`.`temp5`           AS `temp5`,
      `w`.`temp6`           AS `temp6`,
      `w`.`weather1`        AS `weather1`,
      `w`.`weather2`        AS `weather2`,
      `w`.`weather3`        AS `weather3`,
      `w`.`weather4`        AS `weather4`,
      `w`.`weather5`        AS `weather5`,
      `w`.`weather6`        AS `weather6`,
      `w`.`wind1`           AS `wind1`,
      `w`.`wind2`           AS `wind2`,
      `w`.`wind3`           AS `wind3`,
      `w`.`wind4`           AS `wind4`,
      `w`.`wind5`           AS `wind5`,
      `w`.`wind6`           AS `wind6`,
      `w`.`fl1`             AS `fl1`,
      `w`.`fl2`             AS `fl2`,
      `w`.`fl3`             AS `fl3`,
      `w`.`fl4`             AS `fl4`,
      `w`.`fl5`             AS `fl5`,
      `w`.`fl6`             AS `fl6`,
      `w`.`ind`             AS `ind`,
      `w`.`index_xs`        AS `index_xs`,
      `w`.`index_uv`        AS `index_uv`,
      `w`.`index_xc`        AS `index_xc`,
      `w`.`index_tr`        AS `index_tr`,
      `w`.`index_co`        AS `index_co`,
      `w`.`index_cl`        AS `index_cl`,
      `w`.`index_ls`        AS `index_ls`,
      `w`.`index_ag`        AS `index_ag`,
      `w`.`create_time`     AS `create_time`,
      `sk`.`temp`           AS `temp`,
      `sk`.`wd`             AS `wd`,
      `sk`.`ws`             AS `ws`,
      `sk`.`sd`             AS `sd`,
      `sk`.`wse`            AS `wse`,
      `sk`.`time`           AS `time`,
      `sk`.`create_time`    AS `create_time_sk`,
      COALESCE(`air`.`aqi`,0)           AS `aqi`,
      COALESCE(`air`.`level`,'')         AS `level`,
      COALESCE(`air`.`position_name`,'') AS `position_name` 
    FROM (SELECT   * FROM  `ep_weather_report_current`    WHERE `city`='汝州') w
      LEFT JOIN  `ep_weather_sk_temperature_current` `sk` ON `w`.`cityid` = `sk`.`cityid`
      LEFT JOIN   (SELECT * FROM `ep_airpollution_realtime_current` WHERE `city` = `position_name` AND  city = '汝州') `air`
      ON `w`.`cityid` = `air`.`cityid`
    

    因为不知道markdown的颜色如果设置,先单独提取出来,强调一下;欢迎高手markdown高手赐教!

          COALESCE(`air`.`aqi`,0)           AS `aqi`,
      COALESCE(`air`.`level`,'')         AS `level`,
      COALESCE(`air`.`position_name`,'') AS `position_name`
  • 相关阅读:
    tensorflow2.0——简单的三种图像增强方式(翻转,光照,对比度)
    tensorflow2.0——卷积初始化
    tensorflow2.0——实现先卷积后LSTM的网络
    tensorflow2.0——compile-fit实现多输入复合模型
    CMDB-客户端
    saltstack部署
    CMDB实现的四种方式
    理解python中的元类
    RESTful 架构
    Vuex笔记/axios笔记
  • 原文地址:https://www.cnblogs.com/jerrychen/p/4635361.html
Copyright © 2011-2022 走看看