The customer puts forward the requirement and adds subtotal to a group to summarize the total. I found some SQL statements on the Internet. Not ideal. I decided to write it by myself.There are three ideas:1. Many are implemented using GROUPPING and
Mysql_fetch_array-- Get a row from the result set as an associated array or number array, or both
Description: array mysql_fetch_array (resource result [, int result_type])
Returns the array generated based on the rows obtained from the result set.
1. mysql transactions
In MYSQL, only INNODB Data Tables support transaction processing.
There are two ways to start a transaction:
(1)Use begin, rollback, and commit to implementCopy codeThe Code is as follows:Start a transactionRollback transaction
Copy codeThe Code is as follows:#/Bin/sh# Check whether mysql server provides services normallyMysqladmin-u sky-ppwd-h localhost ping# Obtain the Current Status values of mysqlMysqladmin-u sky-ppwd-h localhost status# Obtain the current connection
1. Each client connection is divided into a thread belonging to the server process. The corresponding queries of the connection are all processed by this thread.
2. The Server caches the thread. Therefore, no threads are created or destroyed for
A one-to-multiple table is usually associated with the primary key of another table. However, there are also some unusual situations, that is, two tables are not joined by the primary key of one of the tables.For example:Copy codeThe Code is as
The searchd daemon of sphtracing supports MySQL binary network protocol from version 0.9.9-rc2 and can be accessed through standard MySQL APIs.For example, the "mysql" command line program can work well.
The following is an example of using the
The problem is as follows:The persons table has two fields: id and name.The content in the document persons.txt (tabs are used to separate fields in each line ):1 Bush2 Carter3 BushUse load data local infile into persons.txt "into table persons in
1. index creation time: it is worthwhile to create an index for a field in select, filter, and sort conditions.2. For Fuzzy queries like '% XXX', normal indexes cannot be satisfied, and full-text indexes must be created.3. if there are multiple
SQL:
Copy codeThe Code is as follows:SELECT@ Rownum: = @ rownum + 1 AS rownum,A. order_id,Case when a. Ordered = 1 then 'split into tickets 'end as Ordered,A. printed,A. order_sn,A. user_id,B. user_name,A. consignee,A. tel,A. mobile,A. address,A.
1. Create the path to save the mysql backup file/mysqldata# Mkdir/mysqldata2. Create the/usr/sbin/bakmysql file.# Nano/usr/sbin/bakmysqlInput:Copy codeThe Code is as follows:#! /Bin/shName = 'date + % Y % m % d'Mysqldump -- all-databases-uroot-p
1. query help? Contents2. Use the merged hash value to separate BLOB or TEXT3. Number of points used for currency (decimal or numberic)4. SQL _mode?5. order by rand () limit 1000;6. Optimize show status like 'com' Com_select Com_insert and so on to
Having usage Having clauses allow us to filter various data After grouping. where clauses filter records before aggregation, that is, before group by and having clauses. The having clause filters group records after aggregation.SQL instance:1.
Solution:Step 1: the database and table created during restoration are in utf8 format (utf8 is recommended, of course, either gbk or gb2312)Copy codeThe Code is as follows:Create database 'shegongku 'default character set utf8Create table 'members '(
SET: set global log_bin_trust_function_creators = 1;1. Function func_splitStringTotal: splits the string according to the specified method and calculates the total number of units. Copy codeThe Code is as follows:DELIMITER $Create function 'func _
Preface:
Recently, Oracle MySQL posted some of the 5.6 posts on its official BlogModify the default value of a Variable. WhereInnodb_old_blocks_timeFrom 0 to 1000 (1 s)
The role of this parameter is as follows:
How long in milliseconds (MS) a
I. MySQL stored procedure parameters (in)MySQL stored procedure "in" parameter: similar to the value passing of function parameters in C language, MySQL stored procedure may modify this parameter internally, but modify the in type parameter, not
1. How to create an independent account and Set permissions
Here I use Navicat as my database management tool to open Navicat.
Select "user" -- "create user"
Enter the user name, host, and password. Note that the host name is not "localhost",
Create the mysql_order_by_test data table according to the following table structure. We will use instance to tell you how to use MySQL order.Order by uid ASCQuery data in the forward order of uid, that is, sort data in ascending order of uidOrder
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