32 lines
980 B
MySQL
32 lines
980 B
MySQL
|
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');
|