DQL条件查询

-- DQL条件查询
-- 1,查询ID大于2的信息
select * from agent where AgentID>2; 
-- 2,查询ID大于等于2的信息
select * from agent where AgentID>=2; 
-- 3,查询ID大于2 并且 电话是0810的
select * from agent where AgentID>=2 && phone = 1002;
-- 4.查询AgentID数值大小在2到3之间
select *from agent where AgentID BETWEEN 2 and 3;
-- 查询id等于1的信息
select *from agent where AgentID = 1;
-- 查询id不等于1的信息
select *from agent where AgentID != 1;

-- 7, or 查询或者或者的信息 使用in简化操作
select *from agent where Phone = 0810 or Phone = 1002;
select *from agent where Phone in (0810,1002);
-- 8,查询Phone电话为null的信息
-- 注意:null值得比较不能使用= !=,需要使用is ,is not
select *from agent WHERE AgentID is null;
select *from agent WHERE AgentID is NOT null;

 

 

posted @ 2022-11-09 23:44  YE-  阅读(20)  评论(0编辑  收藏  举报