SQL server 查询语句

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;

猜你喜欢

转载自blog.csdn.net/wangyuxiang946/article/details/118398986#comments_22041618