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`
  • 相关阅读:
    leetcode108 Convert Sorted Array to Binary Search Tree
    leetcode98 Validate Binary Search Tree
    leetcode103 Binary Tree Zigzag Level Order Traversal
    leetcode116 Populating Next Right Pointers in Each Node
    Python全栈之路Day15
    Python全栈之路Day11
    集群监控
    Python全栈之路Day10
    自动部署反向代理、web、nfs
    5.Scss的插值
  • 原文地址:https://www.cnblogs.com/jerrychen/p/4635361.html
Copyright © 2011-2022 走看看