大家好,又见面了,我是你们的朋友全栈君。
select * from test.dbo.users -- 普通条件查询
where id=1;
模糊查询
select * from test.dbo.users
where username like '%li%';
范围查询
select * from test.dbo.users -- id在1~3之间的数据
where id between 1 and 3;
select * from test.dbo.users -- id在1~3以外的数据
where id not between 1 and 3;
子查询
select * from test.dbo.users -- id为1或2或3的数据
where id in(1,2,3);
select * from test.dbo.users -- id不是1或2或3的数据
where id not in(1,2,3);
排序
select * from test.dbo.users -- 从小到大排序
order by id asc;
select * from test.dbo.users -- 从大到小排序
order by id desc;
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/135731.html原文链接:https://javaforall.cn