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