数据库
首页 > 数据库> > 数据库查询汇总

数据库查询汇总

作者:互联网


SELECT * FROM game;
SELECT * FROM 王者荣耀.game AS zz;
SELECT 类型 FROM game;
SELECT DISTINCT 类型 FROM game;
SELECT DISTINCT aa.类型 AS bb FROM 王者荣耀.game AS aa;
SELECT * FROM game WHERE 类型 = '法师';
SELECT * FROM game WHERE 类型 LIKE '法师';
SELECT * FROM game WHERE 类型 = '法师' AND 等级 > 30;
SELECT * FROM game WHERE 类型 = '法师' OR 等级 > 60;
SELECT * FROM game WHERE 类型 LIKE '法师' OR 等级 > 60;
SELECT * FROM game WHERE 等级 BETWEEN 60 AND 80;
SELECT * FROM game WHERE 等级 >= 60 AND 等级 <= 80;
SELECT 等级,姓名 FROM game;
SELECT * FROM game WHERE 姓名 LIKE '李%';
SELECT * FROM game WHERE 姓名 LIKE '%小_';
SELECT * FROM game WHERE 姓名 LIKE '%信%';
SELECT * FROM game WHERE 姓名 LIKE '__信';
SELECT 等级 * 10 AS 'zz' FROM game ;
SELECT 编号 * 等级 AS 'zz' FROM game ;
SELECT * FROM game WHERE 类型 != '法师';
SELECT * FROM game WHERE NOT 类型 = '法师';
SELECT * FROM game WHERE NOT 类型 LIKE '法师';
SELECT * FROM game WHERE NOT 类型 IN ('法师');
SELECT * FROM game WHERE NOT 等级 <= 60;
SELECT * FROM game WHERE 类型 IS NULL;
SELECT * FROM game WHERE 类型 IS NOT NULL;
SELECT * FROM game WHERE NOT 类型 IS NULL;
SELECT * FROM game WHERE 姓名 IN ('李白','李广','武则天')
SELECT * FROM game WHERE 姓名 = '李白' OR 姓名 = '李广' OR 姓名 = '武则天'
SELECT * FROM game WHERE 姓名 LIKE '李白' OR 姓名 LIKE '李广' OR 姓名 LIKE '武则天'

#查询game表的前3行
SELECT * FROM game LIMIT 3  
#查询game表全部信息,并且按"编号"列升序
SELECT * FROM game ORDER BY 编号  
#查询game表全部信息,并且按"编号"列倒序
SELECT * FROM game ORDER BY 编号 DESC  
#查询game表全部信息,并且按"编号"列和"等级"列升序
SELECT * FROM game ORDER BY 编号,等级
#查询game表多少行数
SELECT COUNT(*) FROM game           
#查询game表“等级”列多少行数据
SELECT COUNT(等级) FROM game        
#查询game表“等级”列所有行的和
SELECT SUM(等级) FROM game        
#查询game表“等级”列所有行的平均值
SELECT AVG(等级) FROM game        
#查询game表“等级”列的最大值
SELECT MAX(等级) FROM game    
#查询game表“等级”列的最小值
SELECT MIN(等级) FROM game    
#请查询sell表中,每个用户有多少订单号?
SELECT COUNT(*), 用户号 FROM sell GROUP BY 用户号

标签:数据库,汇总,查询,60,game,法师,类型,WHERE,SELECT
来源: https://blog.51cto.com/u_12723336/2735990