Basic exercises for MySQL database
- Creating a database
![Learn and practice PHP (5)](http://image.codes51.com/Article/image/20151224/20151224152918_1411.jpg)
- Using a database
![Learn and practice PHP (5)](http://image.codes51.com/Article/image/20151224/20151224152918_2505.jpg)
- Creating a table
- char: Fixed length, constant
- varchar: Variable
- Display table
![Learn and practice PHP (5)](http://image.codes51.com/Article/image/20151224/20151224152918_5005.jpg)
- View table structure
![Learn and practice PHP (5)](http://image.codes51.com/Article/image/20151224/20151224152918_5786.jpg)
- Insert data
SHA1(): Encrypt data function, create an encrypted character creation, its length is exactly 40 characters
![Learn and practice PHP (5)](http://image.codes51.com/Article/image/20151224/20151224152918_6724.jpg)
- View all elements
![Learn and practice PHP (5)](http://image.codes51.com/Article/image/20151224/20151224152918_7974.jpg)
-
WHERE conditional statement
![Learn and practice PHP (5)](http://image.codes51.com/Article/image/20151224/20151224152918_8911.jpg)
![Learn and practice PHP (5)](http://image.codes51.com/Article/image/20151224/20151224152919_0005.jpg)
- between … and…
![Learn and practice PHP (5)](http://image.codes51.com/Article/image/20151224/20151224152919_0474.jpg)
-
LIKE / NOT LIKE
- Wildcard _: matches a single character; %: matches If 0 or more characters
- are added with () before the wildcard character, then _ or % are only used as original symbols and have no wildcard meaning.
- Queries with LIKE conditional statements are generally slower because they cannot take advantage of indexes, so this format should only be used when absolutely necessary
![Learn and practice PHP (5)](http://image.codes51.com/Article/image/20151224/20151224152919_1255.jpg)
![Learn and practice PHP (5)](http://image.codes51.com/Article/image/20151224/20151224152919_1880.jpg)
![Learn and practice PHP (5)](http://image.codes51.com/Article/image/20151224/20151224152919_2505.jpg)
-
Sort order by ascending ASC Descending DESC
- The column to be sorted is of type ENUM, and the sorting will be based on the order in which the ENUM values were created in the column.
![Learn and practice PHP (5)](http://image.codes51.com/Article/image/20151224/20151224152919_3911.jpg)
-
limit
- LIMIT Will improve query execution speed, because mysql still has to gather each record together and then truncate the list
-
-
- update, delete
- To prevent yourself from accidentally updating too many rows, you can apply a limit clause to update
- To clear a table, the preferred truncate: TRUNCATE TABLE tablename
- To delete all data in the table and Table itself: DROP TABLE tablename;
- To delete the entire database: DROP DATABASE databasename
![Learn and practice PHP (5)](http://image.codes51.com/Article/image/20151224/20151224152919_6880.jpg)
- concat connection function
![Learn and practice PHP (5)](http://image.codes51.com/Article/image/20151224/20151224152919_8599.jpg)
- concat_ws connection function
![Learn and practice PHP (5)](http://image.codes51.com/Article/image/20151224/20151224152919_9693.jpg)
- length function
![Learn and practice PHP (5)](http://image.codes51.com/Article/image/20151224/20151224152920_0162.jpg)
- format function
![Learn and practice PHP (5)](http://image.codes51.com/Article/image/20151224/20151224152920_0787.jpg)
- concat is used with format function
![Learn and practice PHP (5)](http://image.codes51.com/Article/image/20151224/20151224152920_1412.jpg)
- rand() function
![Learn and practice PHP (5)](http://image.codes51.com/Article/image/20151224/20151224152920_2662.jpg)
- now(), curtime(), curdate( ) function
![Learn and practice PHP (5)](http://image.codes51.com/Article/image/20151224/20151224152920_3912.jpg)
- date_format function
').addClass('pre-numbering').hide();
$(this).addClass('has-numbering').parent().append($numbering);
for (i = 1; i ').text(i));
};
$numbering.fadeIn(1700);
});
});
The above introduces PHP learning and practicing (5), including the content. I hope it will be helpful to friends who are interested in PHP tutorials.