Mysql 多个select查询合并成一个新表

select * from (
(SELECT TAG_NAME as FES_DOT_TAG_NAME1 FROM fes_digital where DOT_NO = (SELECT OFFSET_NO1 from digital_control where TAG_NAME = '[email protected]') and APP_TAG_NAME = '[email protected]') as table1,
(SELECT TAG_NAME as FES_DOT_TAG_NAME2 FROM fes_digital where DOT_NO = (SELECT OFFSET_NO2 from digital_control where TAG_NAME = '[email protected]') and APP_TAG_NAME = '[email protected]') as table2,
(SELECT TAG_NAME as FES_DOT_TAG_NAME3 FROM fes_digital where DOT_NO = (SELECT OFFSET_NO3 from digital_control where TAG_NAME = '[email protected]') and APP_TAG_NAME = '[email protected]') as table3,
(SELECT TAG_NAME as FES_DOT_TAG_NAME4 FROM fes_digital where DOT_NO = (SELECT OFFSET_NO4 from digital_control where TAG_NAME = '[email protected]') and APP_TAG_NAME = '[email protected]') as table4,
(SELECT TAG_NAME as FES_DOT_TAG_NAME5 FROM fes_digital where DOT_NO = (SELECT OFFSET_NO5 from digital_control where TAG_NAME = '[email protected]') and APP_TAG_NAME = '[email protected]') as table5
); 

select * from(
(SELECT OFFSET_NUM from digital_control where TAG_NAME = '[email protected]') as table13,

(select * from (
(SELECT OFFSET_NO1 as FES_DOT_NO1 from digital_control where TAG_NAME = '[email protected]') as table6,
(SELECT OFFSET_NO2 as FES_DOT_NO2 from digital_control where TAG_NAME = '[email protected]') as table7,
(SELECT OFFSET_NO3 as FES_DOT_NO3 from digital_control where TAG_NAME = '[email protected]') as table8,
(SELECT OFFSET_NO4 as FES_DOT_NO4 from digital_control where TAG_NAME = '[email protected]') as table9,
(SELECT OFFSET_NO5 as FES_DOT_NO5 from digital_control where TAG_NAME = '[email protected]') as table10)) 
as table11,


(select * from (
(SELECT TAG_NAME as FES_DOT_TAG_NAME1 FROM fes_digital_ctrl where DOT_NO = (SELECT IF( ISNULL(OFFSET_NO1) || LENGTH( trim(OFFSET_NO1) ) < 1,'-1',OFFSET_NO1) 
FROM digital_control where TAG_NAME = '[email protected]')) as table1,
(SELECT IFNULL((SELECT TAG_NAME FROM fes_digital_ctrl where DOT_NO = (SELECT IF( ISNULL(OFFSET_NO2) || LENGTH( trim(OFFSET_NO2) ) < 1,'-1',OFFSET_NO2) 
FROM digital_control where TAG_NAME = '[email protected]')),'') as FES_DOT_TAG_NAME2) as table2,
(SELECT IFNULL((SELECT TAG_NAME FROM fes_digital_ctrl where DOT_NO = (SELECT IF( ISNULL(OFFSET_NO3) || LENGTH( trim(OFFSET_NO3) ) < 1,'-1',OFFSET_NO3) 
FROM digital_control where TAG_NAME = '[email protected]')),'') as FES_DOT_TAG_NAME3) as table3,
(SELECT IFNULL((SELECT TAG_NAME FROM fes_digital_ctrl where DOT_NO = (SELECT IF( ISNULL(OFFSET_NO4) || LENGTH( trim(OFFSET_NO4) ) < 1,'-1',OFFSET_NO4) 
FROM digital_control where TAG_NAME = '[email protected]')),'') as FES_DOT_TAG_NAME4) as table4,
(SELECT IFNULL((SELECT TAG_NAME FROM fes_digital_ctrl where DOT_NO = (SELECT IF( ISNULL(OFFSET_NO5) || LENGTH( trim(OFFSET_NO5) ) < 1,'-1',OFFSET_NO5) 
FROM digital_control where TAG_NAME = '[email protected]')),'') as FES_DOT_TAG_NAME5) as table5
))
as table12);

Mysql 多个select查询合并成一个新表_第1张图片

你可能感兴趣的:(mysql)