Label: The previous time encountered a stored procedure, one of the parameters is a string, the actual effect is stored in the above is as a query condition processing In the stored procedure, the string is split into a temporary table after the key value, as a query condition, the logical implementation of two processing methods INSERT INTO #t Select Key from Split_function (' passed in string ', ', ') The first is to do a inner
Label:1. Referencing 2 tables (effects with inner join) 1 SELECT from WHERE = 2.INNER Join Join (returns a row if there is at least one match in the table) 1 SELECT from INNER JOIN o
, in a table in the aid and B table Bnameid is two connection fields.
Figure 3 below illustrates the relationship between all the recordsets of a connection:
Figure 3: Connection diagram
Now we're going to talk about one by one of our internal and external connections.
1. Inner connection: Use the inner connection to get the record of the public part of the two tables, that is, the recordset C of Figure
ArticleDirectory
1. Example of replacing inner join with exists:
When using exists, if you can use it correctly, it may increase the query speed:
1. Replace inner join with exists
2. Replace in with exists
1. Example of replacing inner
You can implement an inner join by using the INNER JOIN clause, as long as there is a matching value between the associated fields of the two tables corresponding to the two persisted classes, the inner joins will combine the joins in the two tables. The
, the data consistency is well guaranteed.
Why use Joins?As just explained, breaking data into multiple tables enables more efficient storage (efficient storage), easier manipulation (easy to operate), and Greater scalability (very high scalability). But these benefits come and a price.If data is stored in multiple tables, how can I retrieve that data with a single SELECT statement?The answer is to use a join.It is important to understand that a join
SQL INNER JOIN keyword usage tutorial
When the keyword of inner join is returned, at least one row in the competition is returned.SQL Syntax of INNER JOIN
SELECT column_name(s)FROM table_name1INNER
SQL INNER JOIN keyword usage tutorial
When the keyword of inner join is returned, at least one row in the competition is returned.
SQL Syntax of INNER JOIN
SELECT column_name(s)FROM table_name1INNER
Reference Problem description:
There are three tables:
Student Information table S (sno, sname)
Course information table C (cno, cname, cteacher)
Student-course relationship table SC (sno, cno, scroce)
Question 1: find out the names of all students who have not taken the course taught by Mr. Li Ming.
Question 2: The name of two or more failed students is displayed.
Question 3: find out the names of students who have selected both course "1" and course "2 ".
Main test: group by,
multiplied by the number of rows in the second table.
Do not forget the WHERE clause, and make sure that all connections contain a WHERE clause, otherwise MARIADB will return more data than you need. Similarly, make sure that the WHERE clause is used correctly, and that the wrong filter condition will cause MARIADB to return incorrect data.
Cross-Joins This is the connection type of the Cartesian product.
SELECT Vend_name, Prod_name, Prod_price from Vendors, products ORDER
Business background:ERP system has a program ZPPR0002, each time the MES system release production orders in the ERP.The production order data contains the BOM component, which is the 1500 item information that makes up the finished vehicle.Symptoms:Recently, business staff feedback production order transmission slow, an order to 2 minutes, 80 orders a day, to finish the transmission will be a few hours.Reason:With SE30 debugging, it is found that the program spends 90% of its time on a
Tags: img Connection Inner Example process statistics COM ALT operatorIn a comma-stitched string, the element string passed to the in clause includes more than 1400 elements The two approaches were and E.sspfcityid in (SELECTCAST (value as INT)From String_split (' 110000,310000,120000,210100,210200,210400,210800,211200,350100,350500,350200,350800,350700,350900,441200,441300,440500,44 5100,450100,451000,450800,450300,451100,450200,450900,450500,450400,
the same as that shown above!4: inner join or join; It is the record that the returned field ID exists in both the table votemaster and voter. 5: cross join (full join) cross join without the where Condition A cross
The difference between an inner join and an equivalent connection
url:http://blog.csdn.net/dba_waterbin/article/details/8458193
The inner join is the result set that satisfies the join condition, which is relative to the outer join.Outer joins even if a record is not fou
The main spirit of Inner Join is exclusive, call it exclusivity! That is, the data that does not match the Join rules will be excluded, such as the Supplier Code (SUPPLIERID) of a product that does not appear in the Suppliers table, and this record will be ruled out.Outer Join:Select The syntax of Outer can be omitted, for example you can use a LEFT
This article describes the use of inner join to query/delete/modify, the specific implementation of the following, learning MySQL friends can also learn, I hope to help you
copy the code is as follows:
--Query
SELECT tp.tp_id, TP.TPMC, Tp.leveid, Tp.tpdz, TP.JGM, TP.SCSJ, Tp.pbzyid, TP.KSBFSJ, TP.JSBFSJ, Tp.status, TP.TPBZ from QD Gl_tupian TP INNER
Label:These days of study, only to find that the SQL originally was so not understanding. Have always thought that they can easily deal with a variety of complex SQL queries, but once mentioned efficiency, may be more dumbfounded, and sometimes complain that the client server is not working. As for the inner join three ways: Loop,merge, hash, there are many articles in the garden, say to see many times than
-free Empress','Taoism'),
*('Heavenly Queen','Taoism')
$
Panax Notoginseng--insert these lines into this location - Insert into location theValues'Buddhist','India'),
+('Taoism','China'),
A('Christ','Western'),
the('Confucian','China')
+
---inner JOIN inline, link the teacher table to the location table $--teacher is the main table, location is attached table, with teacher $
---only the matching
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.