mysql-Data manipulation-additions and deletions

Source: Internet
Author: User

1. Increase:

Insert  into Values (value, value, value ...) Insert  into Values (Value, value, Value ... ), (value, value , value ...) Insert  into Select  from table

2. Delete:

Delete  from Table Delete  from where id=1 and name='Alex'

3. Modification:

Update Set ' Alex ' where ID>1

4. Enquiry:

Select *  from Table Select *  from where > 1 Select  as  from where > 1

5. Supplement

A, conditionsSelect *  fromTablewhereId> 1  andName!= 'Alex'  andNum=  A; Select *  fromTablewhereIdbetween 5  and  -; Select *  fromTablewhereIdinch( One, A, -)    Select *  fromTablewhereId not inch( One, A, -)    Select *  fromTablewhereIdinch(SelectNid fromtable) b, wildcard charactersSelect *  fromTablewhereName like 'ale%'  -all (multiple strings) beginning with the aleSelect *  fromTablewhereName like 'Ale_'  -Ale begins with all (one character) C, limitSelect *  fromTable limit5;-Top 5 rowsSelect *  fromTable limit4,5;-5 lines starting from line 4thSelect *  fromTable limit5Offset4    -5 rows starting from line 4th D, sortSelect *  fromTableOrder  byColumnASC              -arrange from small to large according to "column"Select *  fromTableOrder  byColumndesc             -arrange from large to small according to columnsSelect *  fromTableOrder  byColumn 1desc, column 2ASC    -rank from large to small according to column 1, if same, sort by column 2 from small to large e, groupSelectNum fromTableGroup  byNumSelectNum,nid fromTableGroup  byNum,nidSelectNum,nid fromTablewhereNid> Ten Group  byNum,nidOrderNiddesc    SelectNum,nid,Count(*),sum(score),Max(score),min(score) fromTableGroup  byNum,nidSelectNum fromTableGroup  byNum having Max(ID)> Tenin particular:Group  byMust be in the Where,OrderBy before F, no correspondence between the table is not displayedSelectA.num, A.name, B.name fromA, bWhereA.nid=B.nid No corresponding relationship is not displayedSelectA.num, A.name, B.name fromAInner JoinB onA.nid=B.nid A table all display, if there is no corresponding relationship in B, the value is nullSelectA.num, A.name, B.name fromA Left JoinB onA.nid=B.nid B Table All display, if there is no corresponding relationship in B, the value is nullSelectA.num, A.name, B.name fromA Right JoinB onA.nid=B.nid G, combination of combinations, automatic processing of coincidentSelectNickname fromAUnion    Selectname fromB combination, do not handle coincidentSelectNickname fromAUnion  All    Selectname fromB

mysql-Data manipulation-additions and deletions

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.