mysql

#查询game表中的全部信息 SELECT * FROM game; #查询game表中的全部信息,并且在表名前面加库名,给表取别名为zz SELECT * FROM 王者荣耀.game AS zz; #查询game表中的类型一列的信息 SELECT 类型 FROM game; #查询game表中的类型一列的信息,并且去重 SELECT DISTINCT 类型 FROM game; #查询game表中的类型一列的信息,并且去重,给表名和字段前面分别加库名和表名、取别名。 SELECT DISTINCT aa.类型 AS bb FROM 王者荣耀.game AS aa; #查询game表中类型是法师的全部信息(使用三种方法) SELECT * FROM game WHERE 类型 = ‘法师‘; SELECT * FROM game WHERE 类型 LIKE ‘法师‘; SELECT * FROM game WHERE 类型 in ( ‘法师‘); #查询game表中,类型是法师,并且等级大于30的全部信息 SELECT * FROM game WHERE 类型 = ‘法师‘ AND 等级 > 30; #查询game表中,类型是法师,或者等级大于60的全部信息 SELECT * FROM game WHERE 类型 = ‘法师‘ OR 等级 > 60; #查询game表中,等级在60至80的全部信息(包含60和80,使用2种方法) SELECT * FROM game WHERE 等级 BETWEEN 60 AND 80; SELECT * FROM game WHERE 等级 >= 60 AND 等级 <= 80; #查询game表中,等级和姓名两列信息。 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 ‘武则天‘ #在王者荣耀数据库中有dj、lx两张表,请查询每个英雄的所有信息。(使用”编号“进行等值连接,并且使用3种方法) SELECT * FROM dj, lx WHERE dj.编号 = lx.编号 SELECT * FROM dj JOIN lx ON dj.编号 = lx.编号 SELECT * FROM dj JOIN lx USING (编号); #在王者荣耀数据库中,有dj、lx两张表,请查询dj表的全部信息,并且进行左外连接查询。 SELECT * FROM dj LEFT OUTER JOIN lx ON dj.编号 = lx.编号 #查询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 用户号

mysql

上一篇:MySQL数据库从入门到放弃


下一篇:mysql 查询 lock状态