Use of 1.insert_select: Copy data from one table to another
INSERT into students (name,sex,likebooksnum,likesportnum,average)
SELECT
Name,sex,likebooksnum,likesportnum,average
From Students_copy;2.regexp: Use of regular expressions, BINARY is a case-sensitive search
Select students. ' Name ' from students WHERE students. ' Name ' REGEXP BINARY ' Jack ';
3. Aggregate function, COUNT (*), as table alias, GROUP By,with ROLLUP
SELECT Sex, COUNT (*) as Sex_num from students GROUP by sex with ROLLUP;
4, left outer junction left/right OUTER JOIN table column name on junction: Select All rows on the left/right: For example, you can retrieve some columns with a value of NULL
SELECT students. ' Name ', Students.sex,count (sorce.average) as Average_num
From students left OUTER JOIN sorce on Students.average=sorce.average GROUP by students.name;5, using trigger: CREATE TRIGGER (Trigger) A fter INSERT on students_copy updated table for each ROW update execution update means (Students_count SET students_count=students_count+1)
CREATE TRIGGER newname after INSERT on students_copy for each ROW
UPDATE Students_count set students_count=students_count+1;6,update the table set operation directives to manipulate the WHERE query condition: It is important to note that the column name is to avoid the MySQL keyword, For example: name, etc.;
UPDATE students_copy
SET ' students_name ' = "David" WHERE average=100;7, joins table operations, makes operation easier
SELECT
Students. ' Name '
From Students,sorce,books
where Students.average=sorce.average and Sorce.id=books.id and books.id=161034168, the self-junction of the table:
SELECT s1.name,s1.average from students as s1,students as S2 WHERE s1. ' Name ' =s2. ' Name ' and S1. likebooksnum=3;
MySQL Initial learning