0

我从 2 表 miele 和 confmiele 中创建了一个联合,如下所示:

 SELECT datamiele, nomemiele, codicemiele, dataconfmiele, '' AS nomeconfmiele, 
        0 AS  codiceconfmiele FROM miele
 UNION ALL
    dataconfmiele, '' AS nomemiele, 0 AS codicemiele, dataconfmiele, nomeconfmiele,
    codiceconfmiele 
 FROM confmiele

结果正确,但字段 datamiele 和 dataconfmiele 不正确(属于数据字段类型)

Result il like:
datamiele
323031332d30392d3031

为字段编号分配值 0 或为字段 varchar 分配 varchar 给我正确的值。​​但我不知道分配给日期字段是什么?

4

2 回答 2

0

感谢您的解决方案,我从第一次选择中更正了一件事“'' AS dataconfmiele”

我为其他人留下了解决方案

SELECT datamiele, 
        nomemiele, 
        codicemiele, 
        '' AS dataconfmiele, 
        '' AS nomeconfmiele, 
        0 AS  codiceconfmiele 
 FROM miele
 UNION ALL
 SELECT  dataconfmiele AS datamiele, 
         '' AS nomemiele, 
         0 AS codicemiele, 
         dataconfmiele,
         nomeconfmiele,
         codiceconfmiele 
 FROM confmiele

非常感谢您

于 2013-10-09T08:40:14.987 回答
0

通过映射确切的别名来尝试这个

 SELECT datamiele, 
        nomemiele, 
        codicemiele, 
        dataconfmiele, 
        '' AS nomeconfmiele, 
        0 AS  codiceconfmiele 
 FROM miele
 UNION ALL
 SELECT  dataconfmiele AS datamiele, 
         '' AS nomemiele, 
         0 AS codicemiele, 
         dataconfmiele,
         nomeconfmiele,
         codiceconfmiele 
 FROM confmiele
于 2013-10-08T12:16:18.040 回答