Python-day11 Mysql Data class operation

Source: Internet
Author: User

Data class Operation # # #

insert#=====
INSERT into student (sname,gender,class_id) VALUES (' ls ', ' Male ', 1)
Insert into Class (caption) VALUES (' Python1 class ')
Insert into teacher (tname) VALUES (' Alex ')
Insert into course (cname,tearch_id) VALUES (' Python ', 1)
Insert INTO score (Student_id,corse_id,number) values (4,3,60);


update=====
Update score set number=87 where sid=1;

delete===
Delete from score where sid=1;

select====================

selectfrom

select from 表  where id > 1 select nid, name ,gender  as gg  from 表  where id > 1 a、条件      select from 表  where id > 1  and name !=  ‘alex‘ and num = 12;      select from 表  where id  between and 16;      select from 表  where id  in (11,22,33)      select from 表  where id  not in (11,22,33)      select from 表  where id  in ( select nid  from 表) b、通配符      select from 表  where name like ‘ale%‘ - ale开头的所有(多个字符串)      select from 表  where name like ‘ale_‘ - ale开头的所有(一个字符) c、限制      select from 表 limit 5;            - 前5行      select from 表 limit 4,5;          - 从第4行开始的5行      select from 表 limit 5 offset 4    - 从第4行开始的5行 d、排序      select from 表  order by 列  asc - 根据 “列” 从小到大排列      select from 表  order by 列  desc - 根据 “列” 从大到小排列      select from 表  order by 列1  desc ,列2  asc - 根据 “列1” 从大到小排列,如果相同则按列2从小到大排序 e、分组      select num  from 表  group by num      select num,nid  from 表  group by num,nid      select num,nid  from 表   where nid > 10  group by num,nid  order nid  desc      select num,nid, count (*), sum (score), max (score), min (score)  from 表  group by num,nid      select num  from 表  group by num  having max (id) > 10      特别的: group by 必须在 where 之后, order by 之前 f、连表      无对应关系则不显示      select A.num, A. name , B. name      from A,B      Where A.nid = B.nid      无对应关系则不显示      select A.num, A. name , B. name      from inner join B      on A.nid = B.nid      A表所有显示,如果B中无对应关系,则值为 null      select A.num, A. name , B. name      from left join B      on A.nid = B.nid      B表所有显示,如果B中无对应关系,则值为 null      select A.num, A. name , B. name      from right join B      on A.nid = B.nid g、组合      组合,自动处理重合      select nickname      from A      union      select name      from B      组合,不处理重合      select nickname      from A      union all      select name      from B

Other advanced: http://www.cnblogs.com/wupeiqi/articles/5713323.html

Python-day11 Mysql Data class operation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.