This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
justhomework/DB/exp2.sql
2023-04-13 12:17:22 +08:00

31 lines
980 B
SQL

select * from members where m_address like '%湖南%';
select p_no, SUM(o_quantity) as total_quantity
from orders group by p_no
having SUM(o_quantity) > 5
order by total_quantity desc;
select m_account,p_no from orders where p_no in (select p_no from orders where m_account = 'Wangym') and m_account != 'Wangym';
create view View1 as
select * from members
where m_account in (select m_account from orders where p_no = '102');
insert into View1 values ('fengx','冯向','','北京',5000,'fx');
select m.*, o.o_quantity, o.o_date, o.p_no
from members m
left join orders o on m.m_account = o.m_account;
update members
set m_password = 'liu'
where m_account = 'liuzc';
insert into members values ('liuzc','翁红','','湖南株洲','5500','123');
alter table members add constraint m_sex_check check (m_sex in('',''));
insert into members values ('liuzh','刘忠怀','','湖南株洲',3000,'liuzh');
insert into orders values ('Zhou','101',1, '2017-8-9');