This article is the superior operation of the related chapters of the experimental building .
A) Create a database test, switch to the database, create a table in the database test, and insert the data,
1) Create and switch
2) Create a table and insert data
Show all the data in the table:
II) query statements
1) Find the maximum value of the column
Use the max () function to article the maximum value of the item number.
2) Query the row for the maximum value of a column
Displays the row for the Price column's maximum value:
Another way is to sort all the prices in descending order, and then use the MySQL-specific limit words to display one line (specify the first line to show the highest price):
Note: If the price of a number of items is 19.95 (that is, more than one of the most expensive items), then the result of limit display will only be one of them.
3) display the maximum value of the column by group
Use the following code to find out the highest price for each item :
4) Using User variables
Find the item with the highest or lowest price by using user variables
5) Use a foreign key or learn more.
6) Calculate the monthly traffic
Use the Bit_count function to calculate the number of days a user accesses a webpage per month. First, create a table T1 that represents the year-month day when a user visits a webpage:
Use the following statement to query the number of visits per month:
Note: Bit_count () is used to calculate the number of binary numbers containing 1, such as: SELECT Bit_count (10), because 10 becomes a binary number of 1010, the result is 2.
Bit_or () is used to perform or operate on two binary numbers.
After all or operation, the stats are set to 1 bit number to know how many days of the month are accessed.
Small white Study Data blog on this has to explain, interested can see.
MySQL Common query