1. 程式人生 > >MySQL建立檢視和Union all的使用案例

MySQL建立檢視和Union all的使用案例

 CREATE VIEW netcheck.cpu_mp AS
(SELECT
 cpu.ID AS id,
 cpu.chanel_name AS chanel_name,
 cpu.first_channel AS first_channel,
 cpu.IMG_Url AS IMG_Url,
 cpu.lastModifyTime AS lastModifyTime,
 cpu.second_channel AS second_channel,
 cpu.SHOW_TIME AS SHOW_TIME,
 cpu.TASK_Id AS TASK_Id,
 cpu.TITLE AS TITLE,
 cpu.URL AS URL,
 cpu.checkSysTaskId AS checkSysTaskId,
 cpu.innerUUID AS innerUUID,
 cpu.isReject AS isReject,
 cpu.scanTime AS scanTime
FROM channel_page_update_result cpu
)
 UNION ALL
(SELECT
  mp.id AS id,
  '' AS chanel_name,
  '' AS first_channel,
  '' AS second_channel,
  '' AS TITLE,
  mp.imgUrl AS IMG_Url
  ,mp.lastModifyTime AS lastModifyTime,
  mp.showTime AS SHOW_TIME,
  mp.taskId AS TASK_Id,
  mp.url AS URL,
  mp.checkSysTaskId AS checkSysTaskId,
  mp.innerUUID AS innerUUID,
  mp.isReject AS isReject,
  mp.scanTime AS scanTime
FROM mainpageupdateresult mp
);