摘要: create database CDA; use CDA; create table order_tab( order_id int, user_no varchar(3), amount int, create_date date ); insert into order_tab values ( 阅读全文
posted @ 2021-10-06 13:10 charlly 阅读(338) 评论(0) 推荐(0)
摘要: - 子查询 -- 标量子查询: -- 查询基本工资高于公司平均工资的员工信息 select * from emp where sal>(select avg(sal) from emp); -- 练习:查询和allen同一个领导的员工:empno,ename,job,mgr select empno 阅读全文
posted @ 2021-10-06 13:01 charlly 阅读(80) 评论(0) 推荐(0)
摘要: -- 多表连接查询 create table t1(key1 char,v1 int); create table t2(key2 char,v2 int); insert into t1 values('a',1),('a',2),('b',3),('c',4),('a',13); insert 阅读全文
posted @ 2021-10-06 13:00 charlly 阅读(165) 评论(0) 推荐(0)
摘要: -- 聚合运算 -- 查询emp表中员工总数、最高工资、最低工资、平均工资及工资总和 select count(*) as 员工总数, max(sal) as 最高工资, min(sal) as 最低工资, avg(sal) as 平均工资, sum(sal) as 工资总和 from emp; s 阅读全文
posted @ 2021-10-06 12:51 charlly 阅读(164) 评论(0) 推荐(0)
摘要: -- 继续mysql自我练习基础1, 数据和表格沿用基础1-- 单表查询(虚拟结果集) select * from emp; -- 检查表emp所有字段数据内容 -- 查询指定列:查询emp表中ename,job,sal select ename,job,sal from emp; -- 设置别名: 阅读全文
posted @ 2021-10-06 12:48 charlly 阅读(196) 评论(0) 推荐(0)
摘要: -- 查看系统中有哪些数据库 show databases; -- 创建test数据库 create database test; -- 选择进入数据库 use test; -- 删除数据库(慎用) drop database test; -- 创建数据表 create database test; 阅读全文
posted @ 2021-10-06 12:37 charlly 阅读(71) 评论(0) 推荐(0)
摘要: import random # 随机产生一个1 - 10之间的数字 # 猜测数字,若猜小了,提示小了。猜测大了,就提示大了。总共猜3次 a = random.randint(1, 10) print("a:", a) i = 0 while i < 3: number = input("请猜数字(1 阅读全文
posted @ 2021-10-06 11:57 charlly 阅读(65) 评论(0) 推荐(0)