When we enter data regardless of the case, for example: Enter AAA or AAA, AAA can query the same results, indicating that the query condition is not sensitive to case.Solution One:So I doubted the MySQL problem. Do an experiment: Use the client
Transferred from: http://blog.csdn.net/kevinlifeng/article/details/43233227Statement is their own study is not original, hope everyone support the original.SQL statement optimization and indexing1.Innerjoin and left connection, right connection, sub
From:http://www.cnblogs.com/xuxm2007/archive/2010/11/16/1878211.htmlSELECT * FROM table LIMIT 5;SELECT * FROM Issu_info limit 0,6Limit 0,6Here's the right one, showing the top 6.SELECT * FROM Issu_info limit 7, 6;Limit 7,6Starting from 8th, take 6
Basic QueryRemoval of duplicate records >select DISTINCT vend_id from the products;Paging >select * from the products LIMIT 5;>select * from the products LIMIT 0, 5;>select * from the Products LIMIT 5, 5;Sort (Descending) >select * from the products
Data Preparation:To Create a table:CREATE TABLE students (ID int unsigned primary key auto_increment not NULL,name varchar ("default"),Age tinyint unsigned default 0,height Decimal (5,2),gender enum (' Male ', ' female ', ' shemale ', ' secrecy
Why query speed is slowBefore trying to write a quick query, we need to be clear that what really matters is response time. If you think of a query as a task, it consists of a series of subtasks, each of which consumes a certain amount of time. If
#group by
#group by + group_concat ()
#group by + aggregate function
#group by + have
#group by(1) Meaning of GROUP by: Group The results of the query in 1 or more fields, with the same field values as a group(2) Group by can be
Federated QueriesSelectA.*, B.adress, B.name fromA, bwhereA.sbno=B.cdidOrder byA.sbno, A.stimeSelect a.a_id, A.a_name, b.b_name from a A, b a where a.b_id = b.b_id // Union query Insert intoTable1 (XX,YY,ZZ)SelectXx,yy,zz fromtable2;SelectAxx asID,
Poor query performance is due to access to too much data
All columns are returned when a multi-table connection is made
select * from sakila.actor inner join sakila.file_actor using(actior_id)inner join sakila.film using(film_id)where
A1, look for redundant records in the table, duplicate records are based on a single field (Peopleid) to determine the select * from Peoplewhere peopleid in (select Peopleid from people GROUP by Peopleid Having count (Peopleid) > 1) 2, delete
Today:SELECT * FROM table name WHERE to_days (Time field name) = To_days (now ());Yesterday:SELECT * FROM table name WHERE to_days (now ())-To_days (Time field name) 7 days ago:SELECT * FROM table name where Date_sub (Curdate (), INTERVAL 7 day) 30
Show variables like ' character% ';The results are as follows:+--------------------------+---------------------------------------------------------------+| variable_name | Value|+--------------------------+--------------------------------------------
1. Copy the following statements to the SQLYOG query bar/*!40101 SET NAMES UTF8 */;CREATE TABLE ' T_student ' (' ID ' double,' Stuname ' varchar (60),' Age ' double,' Sex ' varchar (30),' Gradename ' varchar (60));Insert INTO ' t_student ' (' IDs ',
From_unixtime () is the time function in MySQLDate is the parameter that needs to be processed (the parameter is a UNIX timestamp), can be a field name, or it can be a Unix timestamp stringThe following '%y%m%d ' is primarily the formatting of the
1. Query fields#查询所有字段#查询指定字段2. Querying a specified record (where condition expression)#比较#指定范围#指定集合#匹配字符#查询空值#带IN关键字的集合查询range Query #带BETWEEN and keyword#带LIKE的字符匹配查询#带AND | Multi-criteria query for or3. Further operation of the query
First, simple query1. Most simple query (check all data)Select * from table name Note: * represents all columns and does not represent all rowsExample: SELECT * FROM Test2. Querying a specified columnSelect column name, column name from table
http://zhangzhaoaaa.iteye.com/blog/1689412 reference: "MySQL Technology insider SQL Programming"SELECT DISTINCT From lefttablejoin On WhereGroup Bywith{cube| ROLLUP}HavingOrder byLimitProcessing order
From
On
Join
where
GROUP BY
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.