查询表中有多少行记录

Posted tonggc1668

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了查询表中有多少行记录相关的知识,希望对你有一定的参考价值。

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Repository;

import com.yd.common.data.CIPPageInfo;
import com.yd.common.data.CIPReqCondition;
import com.yd.common.exception.CIPDaoException;
import com.yd.common.runtime.CIPErrorCode;
import com.yd.iwmsc.data.IWMSC_Order_in_finish_headerData;
import com.yd.iwmsc.data.IWMSC_Order_in_finish_itemData;
import com.yd.wmsc.busi.dao.impl.WMSC_busi_inboundDaoImpl;
import com.yd.wmsc.busi.pojo.data.WMSC_busi_inboundData;
import com.yd.wmsc.busi.pojo.po.WMSC_busi_inboundPO;
import com.yd.wmsc.util.YDAssert;

    @Autowired 
    NamedParameterJdbcTemplate jdbcTemplate;

    public int queryDocNum(String ex_wh_code, String ref_doc_id,String owned_cust_id){
        Integer num =null;
        String sql = "select count(1) from wmsc_busi_inbound where ex_wh_code = :ex_wh_code and ref_doc_id = :ref_doc_id  and owned_cust_id = :owned_cust_id";
        Map<String, String> params = new HashMap<String, String>();
        params.put("ex_wh_code", ex_wh_code);
        params.put("ref_doc_id", ref_doc_id);
        params.put("owned_cust_id", owned_cust_id);
        try {
            num = jdbcTemplate.queryForObject(sql, params,Integer.class);
        } catch (Exception e) {
            log.error(e);
            throw new CIPDaoException(CIPErrorCode.ERROR_DATABASE_TECH_EXCEPTION);
        }
        return num == null? 0:num;
    }

 

以上是关于查询表中有多少行记录的主要内容,如果未能解决你的问题,请参考以下文章

mysql中,怎样查询一个表中有多少记录!

Firebase中有多少记录/行/节点?

MySQL如何查询多少行,多少列

在 MongoDB 中,查找所有行 ID 不在给定列表中的记录的查询时间复杂度是多少?

C# ado.net基础 查询一个表中有多少行数据 在sqlsever中的一个表中

您网站上的自定义 jQuery 脚本中有多少行代码?多少才算太多?