UPDATE sc
SET sc.grade = sc.grade-5
where cno in(select cno from course where cname='高等数学') and grade is not null
order by grade
limit 3;
DELETE sc
from sc,course
where cname='数据库基础' and sc.cno=course.cno;
DELETE from course
where cname='数据库基础';
update sc,(select sno from student where sname='王大力')as s1,(select cno from course where cname='计算机导论')as c1
set grade = 70
where s1.sno = sc.sno and c1.cno= sc.cno;
update sc,(select sno,avg(grade) from sc group by sno having avg(grade)>=75)as s2
set grade = grade+5
where sc.sno =s2.sno;
update department,
(select dept_id,count(*) as snum from employee group by dept_id)as num1
set emp_num = snum
where num1.dept_id = department.dept_id;
CREATE VIEW v_customer
AS
SELECT customer_id,customer_name,contact_name,phone,address
FROM customer
WHERE city in("上海","北京");
CREATE VIEW v_order
AS
SELECT customer.customer_id,customer_name,count(order_id),sum(total_money)
from customer,`order`
where YEAR(order_date)=2016 and city="上海" and customer.customer_id = `order`.customer_id
GROUP BY customer.customer_id