一、动态SQL

 动态SQL,主要用于解决查询条件不确定的情况:在程序运行期间,根据提交的查询条件进行查询。

 动态SQL,即通过MyBatis提供的各种标签对条件作出判断以实现动态拼接SQL语句。

二、使用动态SQL原因

 提供的查询条件不同,执行的SQL语句不同。若将每种可能的情况均逐一列出,就将出现大量的SQL语句。

三、<if/>标签

注意事项:

MyBatis_动态SQL

 

(1)

 

1 @Test
2     public void test08() {
3         Student stu = new Student("明", 20, 0);
4         List<Student> students = dao.selectStudentsByCondition(stu);
5         for (Student student : students) {
6             System.out.println(student);
7         }
8 
9     }
com.jmu.test.MyTest

相关文章:

  • 2021-09-06
  • 2021-08-12
  • 2021-12-15
  • 2021-12-06
  • 2021-06-02
  • 2022-01-01
猜你喜欢
  • 2021-07-01
  • 2022-12-23
  • 2021-11-13
  • 2022-02-28
  • 2022-12-23
  • 2022-12-23
  • 2021-11-15
相关资源
相似解决方案