MySQL basic operation (emphasis)

Source: Internet
Author: User
Tags logical operators

    1. Display Database

      Show  
    2. Enter the specified database

      Use database name
    3. Create a database
      Create database name default character Set=utf8
    4. Deleting a database
      Drop database name

Second, the operation of the database table

  1. To create a table:
    Create Tabale studentinfo (name varchar (not null,sex char(ten) null,age int (5), Phone bigint (one)) Studentinfo The name of the table you created
  2. Delete a table
    drop table name;
  3. Add Table Data
     #   add one data at a time   Insert into Studentinfo (name,sex,age) VALUES (  "  Lai poetry   ", "   female  , "  12   ) 
     #   add more than one data at a time   Insert into Studentinfo (name,sex,age) VALUES (  "  Lai poetry   ", "   female  , "  21   "), ("   poetry   ", "   female  , "  22   " ) insert into table name (field name, multiple at, interval) values (specific values multiple at, interval)  
  4. Modify
    ' Li Poetry ' ' Poems of Small poems '
  5. Delete
     from table name where condition

Simple query of database tables (a simple small example)

  1. Find all people
     from people
  2. Only the person's name and age are queried
     from people
  3. What are the people aged 20?
     from '  - '
  4. What are the people who look for a 60-year-old?
     SELECT * from  people where P_age <  " Span style= "COLOR: #800000" >60   "  Find people ages 60 years old Select  * from  people where p_age <> "  60   "  (recommended, official) Select  * from  people where p_age! = Span style= "COLOR: #800000" > " 60  "  Span style= "COLOR: #000000" > (unconventional) common logical operators  <, =, <=, >=, <>,! = 
  5. What are the people over the age of 50 who have a salary greater than 8000?
     from people where p_age > 50 | | P_sal < 8000#   Note: and is used to connect two conditional representations and meaning #or           to connect two conditional representations or meanings
  6. Find the person surnamed Zhang
     from p_name like ' Zhang% ',

    SELECT * from Prople wherer p_name like '% sheet% '
    # There's a word in the middle #
  7. Find out which people belong to the Wudang Huashan Songshan
    SELECT * fromPeople where P_menpai ='Wudang' orP_menpai ='Huashan' orP_menpai ='Songshan'; Select* fromPeople where P_menpaiinch('Wudang','Huashan','Songshan');#No: not in
  8. What are the people who inquire about the salary at 5000-8900?
     from  and P_sal <= 8900 from and 8900;
  9. Query all people, ask for a sort of reverse wage
     from people where p_sal > The ORDER by p_sal ask
  10. Find the leader of a person aged 21 years
    # Select P_learder from people where p_age = ' + ' # SELECR * from people where p_id = ' p003 '  from'+')

MySQL basic operation (emphasis)

Related Article

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.