将两个表中查出的两列信息放在同一个表中

Posted 易之盛技术团队-成长之路

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将两个表中查出的两列信息放在同一个表中相关的知识,希望对你有一定的参考价值。

 String sql_gd = "select * from TAX_INFO_GD where ID=\'"+gdid+"\'";
        Record gdRecord = Db.findFirst(sql_gd);
        String sql_sy = "select * from TAX_INFO where ID=\'"+syid+"\'";
        Record syRecord = Db.findFirst(sql_sy);

        String[] heardArr = {"纳税人识别号:","纳税人名称:","法定代表人:","法人身份证:","注册地址:","经营地址:","经营范围:","从业人数:","注册登记类型:","行业明细:","企业电话:","注册资本:","投资总额:"};
        String[] gdArr = {"SH_ID","NAME","FANREN","FR_ID","ZXDZ","SCJYDZ","JYFW","CYRS","DJZCLX","HANGYE","SCJY_TEL","ZCZB","TZZE"};
        String[] syArr = {"SHXYDM","NSR","FAREN","FRSFZ","ADDRESS","经营地址","JYFW","CYGR_NUM","ZCDJLX","TRADE","企业电话","ZCZB","投资总额"};

        //需要经过处理和填充的新List
        List<Record> newList = new ArrayList<>();
        for(int i=0;i<13;i++){
            Record record = new Record();
            record.set("HEARD",heardArr[i]);
            record.set("GD",gdRecord.get(gdArr[i]));
            record.set("SY",syRecord.get(syArr[i]));
            newList.add(record);
        }
        renderJson(newList);

使每一行均是   HEARD、GD、SY一一对应

产生如图所示

 

 

以上是关于将两个表中查出的两列信息放在同一个表中的主要内容,如果未能解决你的问题,请参考以下文章

如何将两个表与 SQL Server 中第二个表中引用同一列的两列连接起来

如何将两个单独表中的两列拆分为视图中的多行?

SQL - 对两个表中的两列求和并写入新列

Mysql比较两个表中的两列

连接来自两个不同表的两列

怎样一个表中的2个查询结果合并到一个表中的两列