Whenever you query a database, you want to know how many classes you have, or you want to know how many of them are not the same, you use Group statements GROUP by
How to use:
The code is as follows
Copy Code
SELECT *
In the face of rapid business development, one of the important tasks of DBA is to discover the inefficient SQL statements in the database in time, some can immediately start to solve (such as lack of appropriate indexes), and some need to feedback
In fact, for many people have forgotten a lot of SQL statements, or do not understand a lot, because there is a database graphics operation software, convenient for everyone, but we can not forget the most fundamental things, especially some of the
The company website has the need for User name verification to verify the case. In fact, at the beginning of his registration is all the case, so there is no need to do the case verification. But now to log in the case of the verification, it is
Ifnull (EXPR1,EXPR2)
If EXPR1 is not NULL, then the return value of Ifnull () is expr1; Otherwise, its return value is EXPR2. The return value of Ifnull () is either a number or a string, depending on the context in which it is used.
Mysql> SELECT
If you have a table that looks like this:
ID
name
1
Tom
2
John doe
3
Harry
We generally query multiple data when the condition is usually a certain intervalsuch as: ",",
The creator of the stored procedure owns the alter, create, execute permissions for the stored procedure.
MySQL imported through the database, when there are stored procedures, after the import of stored procedures can not use the program, for a
Today, the company server, Tomcat to read the data in MySQL, incredibly can not read the success, looked at the next Tomcat log, found that there is a sentence contains the letter of the case, in order to solve this problem, online search,
One, FORMAT (x,d)
Format the number x to resemble the format ' #,###,###.## ', rounded to D for decimal. If D is 0, the result will not have a decimal point and fractional part.
Example:1.
The code is as follows
Copy Code
To implement paging, we typically use the SELECT * from table where ID >100 limit a,b, when paging is too large, such as reaching 10,000 pages, at this point a = 100,000, b=10, although the index is used here (no indexing will be more Bad), but the
1.order by Rand ()
The data is very slow, the randomness is very good, suitable for very small amount of data.
The code is as follows
Copy Code
SELECT * FROM table_name as R1 JOIN (select ROUND (RAND () * (select ABS (
You can see the ID field at this time the increment is starting at 1000 and has grown to 1002select * from K1;+------+--------+| ID | name |+------+--------+| 1000 | Xiaoke || 1001 | Xiaoke || 1002 | Xiaoke |+------+--------+Take a look at this
How to view all authorized usersSELECT DISTINCT CONCAT (' User: ', user, ' @ ', host, '; ') as query from Mysql.user;Revoke permissions that have been given to the MySQL user.Revoke is similar to Grant's syntax, just replace the keyword "to" with
MySQL stored procedures and functions
Basic concepts:
Creating stored procedures and functions is the combination of a frequently used set of SQL statements and storing these SQL statements as a whole in a MySQL server. For example,
mysql is a , developed by the Swedish MySQL AB company, currently belonging to &NBSP, oracle products. MySQL's most popular relational database management system MySQL is one of the best applications for WEB applications. MySQL Database
Mysql limit paging optimization details, mysqllimit
Mysql limit paging Optimization
10 data records are also retrieved.
select * from yanxue8_visit limit 10000,10
And
select * from yanxue8_visit limit 0,10
It is not an order of magnitude.
There are
Summary of implicit conversions of MySQL and summary of mysql
Preface
I saw an article a few days ago: the implicit conversions of MySQL with millions of values are quite good, and I am not very clear about the implicit conversions of MySQL, so I
Mysql uses one table to update another table. mysql updates another table.
Solution 1: Modify 1 column
Update student s, city cSet s. city_name = c. nameWhere s. city_code = c. code;
Solution 2: Modify multiple columns
Update a, B
Set a. title =
Install innodb_ruby and centosinnodb_ruby in centos 6
Innodb_ruby is a program of jeremycole used to analyze Innodb-related structures. It is also a very convenient structure tool for us to study Innodb. So here is an introduction.
Jeremycole
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