0
点赞
收藏
分享

微信扫一扫

SpringjdbcTemplate模糊查询

水墨_青花 2022-03-15 阅读 35

1、SQL语句拼接

  //1)根据名称模糊查询账户信息,可以返回多个记录
    public List<Account> getAccountByLike(String name) {

        String sql="select * from account where name like '%"+name+"%'";
        List<Account> accountList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(Account.class));
        return accountList;
    }


2、测试:

   @Test
    public  void test06()
    {
        List<Account> accountList=accountDao.getAccountByLike("白");
        for(Account account:accountList)
        {
            System.out.println("account="+account);
        }
    }

3、 运行结果:

在这里插入图片描述

举报

相关推荐

es模糊查询

mongodb模糊查询

WPF模糊查询

分页模糊查询

0 条评论