ARTICLE DETAIL

资讯详情

深耕网站建设、视觉设计与SEO优化的一线实战洞察。

SQL数据查询语句

SQL数据查询语句

表名products,包含列name,price

简单查询:

搜索所有行所有列:

select * from products;

搜索指定列name

select name from products;

搜索指定列并为列取一个假名 名字

select name as 名字 from products;

搜索指定列并为表取一个假名items

select  items.name from products as items;

比较查询          >     <            =          >=           <=           !=

搜索大于1000的价格

select  price from product where p;rice > 1000;

逻辑查询and or  not

#and
select * from products where price>1000 and price <4000; 
#or
select * from products where price > 1000 or price <4000;#not
select * from product wheere not price > 1000

 

范围查询

#between.... and... 闭区间查询连续的
select * from products where price between 1000 and 4000;#in 查询不连续的括号里的值
select * from products where price in (999, 1000,789);

非空判断:

#查询price是空值的
select * from products where price is null;
#查询price不是空值的
select * from products where price is not null;

 

 

 

 

 



返回列表