动态sql where if where可以自动处理第一个and. <!-- 根据id查询用户信息 --> <!-- public User findUserById(int id); --> <select id="findUserById" parameterType="user" resultType="user"> select * from user <!-- 当有if条件成立时,where会自…
普通查询:select * from t; 去除重复值:select distinct f1,f2 from t; between用法:select * from t where f1 not/between 1and 2; like用法:select * from t where f1 not/like '_MDB%'; in用法:select * from t where f1 not/in (n1,n2..); 显示前5行:select * from t where rownum<=5;…
数据库的查询操作是重点中的重点,最核心的内容就是它! 在查询时关键字的定义顺序: select distinct(select-list) from (left-table) (type-join) join (right-table) on join(condition-联结两个表的条件) where (where-condition 查询条件) group by (group-by-list分组条件) having (having-condition基于分组的筛选条件) order by (…
离散查询select * from car where price=30 or price=40 or price=50 or price=60;select * from car where price in(30,40,50,60)取出数据select * from car where price not in(30,40,50,60)去掉数据 聚合函数(统计查询)select count(*) from carselect count(code) from car #取所有的数据条数sel…