MySQL Common statements

Source: Internet
Author: User
Tags joins

1, view database: show databases;

2, using Database: Use database name;

3, Enquiry form: Show tables;

4, view table structure :desc table;

4, CREATE TABLE, delete table, modify etc settings, Navicat can be easily done, not recorded

5, add, delete, change, check, the following table for example

Note the symbol to switch to English Ah!

Add: INSERT into Student value (10, "Zhang San", "male");

Delete: Delete from student where id=3;

Modified: Update student set name= "John Doe" where id=9;

Query: SELECT * FROM Score ORDER BY socre Desc;

1, select * from Message ORDER by r_send_time desc limit

2,update message Set r_phone= "17300060001" Where id = 4

3,select Student.name,score.socre from score left joins student on Score.s_id=student.id where sex= "male" group by subject Ord ER by score.socre desc;

or

Select A.name,b.socre from score B left joins student A on b.s_id=a.id where sex= "male" group by subject ORDER BY B.socre DESC ;

JOIN is broadly divided into three categories as follows:

INNER Join (inner connection, or equivalent connection): Gets a record of the field matching relationship in two tables.

Left  join (left connection):gets all records for the left table, even if the right table does not have a matching record.

Right  Join (right connection):In contrast to the left JOIN, it is used to get all the records in the right table, even if there are no matching records.

6, Character Set encoding:

Show VARIABLES like ' character_set_% '-- View all character set encoding entries

Set the encoding format

Set character_set_client = GBK;
Set character_set_results = GBK;
Set character_set_connection = GBK;

MySQL Common statements

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.