WHERE or HAVING search conditions. Searches all rows in the left table referenced by the left outer join and all rows in the right table referenced by the right outer join. CompleteAll rows of the two tables in the join operation are returned.5. subquery
Use the select result of one query as the condition of another q
(T.taskid,'__')= IsNull(N.taskid,'__')Group byT.taskidThe execution plan is as follows: (this looks much simpler than the above, imagine that performance will improve)When the amount of data is large, the performance aspect of using the left join will be greatly improved, note that when on, the null value is converted using IsNull.The two methods can be very dif
Mysql Database SQL Optimization-subquery optimization and mysql Database SQL Optimization1. What are subqueries and table join queries:Subquery: The select statement is used in the select or where clause of the primary SQL statement; select. name, (select B. name from B where B. id =. id) from a where. name lik 'a %'Ta
'. ' St_stock_m 'WHERE(' ma '. ' St_stock_m '. ' Goods_no '='1230480') and (CACHE>(' ma '. ' m '. ' Cell_no ')=' ma '. ' st_stock_m '. ' Cell_no ')))) and(' ma '. ' loc '. ' Cell_no ')=' ma '. ' m '. ' Cell_no ')) Execution plan In fact, the subquery returns no more than 3 result sets, usually we think that the internal will be based on the use of the result set to check, the efficiency will be very fast, but it is not Thought the internal operati
| +------+--------+------+------+------+-----------+--------------+ 1 row in Set (0.00 sec) mysql>
Example: Querying employee and Department tables using an inner join and displaying query results in ascending order of the age field mysql>
mysql> Select Num,name,employee.d_id,age,sex,d_name,function-From
employ
. CUSTOMER_ID;
Therefore, there is no need to make a right join in MySQL. Doing a right join may even reduce the database performance.
The following is an example
The Code is as follows:
Copy code
Table A records the following:AID aNum1 a200501112 a200501123 a200501134 a200501145 a2005011
the local blog, right and wrong, and there was no time series to sort it out. This articleArticleSort out the concept of the join method for your reference. By checking the information to understand the various concepts mentioned in it, we can continue to verify and summarize the concepts in practice, so that we can fully understand the database step by step.
I only know more about SQL Server 2000, but this does not prevent me from optimizing SQL s
local blog, right and wrong, and there was no time series to sort it out, in this article, we will sort out the concept of the join method for your reference. By checking the information to understand the various concepts mentioned in it, we can continue to verify and summarize the concepts in practice, so that we can fully understand the database step by step.
I only know more about SQL Server 2000, but this does not prevent me from optimizing SQL s
MYSQL subquery and nested query optimization instance parsing, mysql nested instance Parsing
Query the highest score of the game history score of 100
SQL code
SELECT ps.* FROM cdb_playsgame ps WHERE ps.credits=(select MAX(credits) FROM cdb_playsgame ps1 where ps.uid=ps1.uid AND ps.gametag=ps1.gametag) AND ps.gametag='yeti3' GROUP BY ps.uid order by ps.credits
delete (reference alias T1), and then on the connection in the table-with a subquery get, (reference alias T2), the condition of the connection is the same name, but the same is not all deleted, but rather delete the larger record ID number (the ID number in the table above is the same name under the small ID).
delete t1 from tdb_goods as t1 left join(select goods_id,goods_name from tdb_goods group b
local blog, right and wrong, and there was no time series to sort it out, in this article, we will sort out the concept of the join method for your reference. By checking the information to understand the various concepts mentioned in it, we can continue to verify and summarize the concepts in practice, so that we can fully understand the database step by step.
I only know more about SQL Server 2000, but this does not prevent me from optimizing SQL s
optimization post on the local *** Og, right and wrong, and there was no time series to sort it out, in this article, we will sort out the concept of the join method for your reference. By checking the information to understand the various concepts mentioned in it, we can continue to verify and summarize the concepts in practice, so that we can fully understand the database step by step.
I only know more about SQL Server 2000, but this does not preve
Transfer from http://blog.itpub.net/22664653/viewspace-1692317/An introductionI believe many development/dba in the process of using MySQL, the way that MySQL handles multi-table association or performance has been not satisfied. For the development of a submitted query with joins, it is generally more resistant, which suggests splitting the
Processing, I think of oracle. Along the way, I recorded a lot of optimization post on the local blog, right and wrong, and there was no time series to sort it out, in this article, we will sort out the concept of the join method for your reference. By checking the information to understand the various concepts mentioned in it, we can continue to verify and summarize the concepts in practice, so that we can fully understand the database step by step.
MySQL does not support subquery optimization.
1. Create a table
Create table tt1 (id int primary key, c1 INT );Create table tt2 (id int primary key, c2 INT );Insert into tt1 values );Insert into tt2 values (1, 2), (2, 2 );
2. Execution Plan and Problems
Mysql> explain extended select tt1.c1, (SELECT tt2.c2 FROM tt2 WHERE c2 = 10) FROM tt1, tt2;+ ---- + ----------
Label:Although there is a connection query in MySQL to implement a multi-table connection query, but the performance of the connection query is poor, so there is a subquery.1, in theory, the subquery can appear anywhere in the query statement, but the actual application is more than now from after and where. A
Query data refers to obtaining the required data from the database. Query data is the most commonly used and most important operation in database operations. Users can use different query methods according to their needs for the data. Different data can be obtained through different query methods. In MySQL, a SELECT statement is used to query the data. The content to be covered in this chapter.
1, the basic syntax of the query statement2. Query data
1. Create a table createtablett1 (idintprimarykey, c1INT); createtablett2 (idintprimarykey, c2INT); insertintott1value
Create table tt1 (id int primary key, c1 INT); create table tt2 (id int primary key, c2 INT); insert into tt1 value
1. Create a table
Create table tt1 (id int primary key, c1 INT );Create table tt2 (id int primary key, c2 INT );Insert into tt1 values );Insert into tt2 values (1, 2), (2, 2 );
2. Execution Plan and Problems
Mysql>
MySQL is a relational database management system developed by the Swedish Mysqlab Company and currently belongs to Oracle products. MySQL is one of the most popular relational database management systems, and MySQL is the best RDBMS (Relationaldatabasemanagementsystem, relational database management system) application software for Web applications.MySQL support
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.