#在 RUNOOB 数据库中创建数据表runoob_tbl
use runoob;
CREATE TABLE IF NOT EXISTS `runoob_tbl22`(
`runoob_id` INT UNSIGNED AUTO_INCREMENT,
`runoob_title` VARCHAR(100) NOT NULL,
`runoob_author` int(11) NOT NULL,
`submission_date` DATE,
PRIMARY KEY ( `runoob_id` )
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
#删除数据表
drop table `runoob_tbl22`;
#插入数据
insert into `runoob_tbl22`(runoob_title,runoob_author,submission_date )
values ("学rrr", "菜rr", now());
#MySQL 查询数据
select * from runoob_tbl22;
SELECT * from runoob_tbl22 WHERE runoob_title='学习mysql2';
#MySQL UPDATE 查询
UPDATE runoob_tbl22 SET runoob_title='学习 C++' WHERE runoob_id=3;
#DELETE 语句
DELETE FROM runoob_tbl22 WHERE runoob_id=2;
#MySQL LIKE 子句
SELECT * from runoob_tbl22 WHERE runoob_author LIKE '菜鸟%';
#求最大值
SELECT MAX(runoob_author) AS max_runoob_author FROM runoob_tbl22;
#求最小值
SELECT min(runoob_author) AS min_runoob_author FROM runoob_tbl22;
#求和
SELECT SUM(runoob_author) AS nums FROM runoob_tbl22;
#平均值
SELECT AVG(runoob_author) AS CountAverage FROM runoob_tbl22;
#查询排序order by
SELECT runoob_title, runoob_author FROM runoob_tbl22 ORDER BY runoob_title; #(以字母顺序显示runoob_title名称)
SELECT runoob_title, runoob_author FROM runoob_tbl22 ORDER BY runoob_title DESC; #(以逆字母顺序显示runoob_title名称)