SQL statements use left Outer Join instead of in to delete multiple records
Using the in statement as a condition for deleting multiple records is not only inefficient, but also limited by the maximum number of in sets (1000, an error will be reported if this number is exceeded, if the in statement is used as the condition for deleting multiple records, there is
In order to further the left outer connection, we do some tests, and the outer joins are written in several forms, and we can trace to the final SQL conversion form by 10053.--Initialize dataCREATE TABLE A(ID number,Age Number);CREATE TABLE B(ID number,Age Number);INSERT into A values (1,10);INSERT into A values (2,20);INSERT into A values (3,30);INSERT into B va
1) Internal connectionSelect a.*,b.* from a inner join B on a.id=b.parent_idThe result is1 Sheets 3 1 23 12 Lee 42 34 22) Left connectionSelect a.*,b.* from a LEFT join B on a.id=b.parent_idThe result is1 Sheets 3 1 23 12 Lee 42 34 23 Wang Wu Null3) Right connectionSelect a.*,b.* from a right
Dictionary operation
C #
VaR vhe =NewDictionary VaR querystring = context. Request. querystring;Foreach(StringItemInQuerystring ){Vhe. Add (item, commonfunc. convertobjecttostring (querystring [item]);}ReturnVhe;For the above C #
CodeUse LINQ to object for coding
Linqtoobject
1:
VaR query = from itemInQuerystring. oftype NewKeyvaluepair String,String> (Item, querystring [item]); var vhe =NewDictionary Foreach(VAR itemInQuery) {vhe. Add (item. Key. tostring (), i
Left join: to the Left; Right connection: to the right
The first part, the connection inquiry
One, inner connection
The INNER JOIN query operation lists the rows of data that match the join criteria, which compares the column values of the connected columns using comparison
First, the simplest is a one-to-many connection, such as:Select student from Teacher t join t.students student where student ....What if it's many to one? There are implicit and explicit differences (the one-to-many scenario above is implicit). Can be like thisSelect student from student student where student.teacher.age>30This is implicit, and hibernate automatically connects to the teacher table. You can also display a connection like this:Select st
The current hive does not support the syntax for a non in that contains a query clause, and the following HQ statement is not supported:
Query data in the key field in table A, but not in table B
Select A.key from a where key not in (select key from B) This statement is not supported in hive
Queries can be made through the left outer join (assuming that the
Recent BA user feedback has two seemingly very similar statements return the number of results is not the same, more strange, doubt is not hive bug
Query 1 Returns the number of results 6071
Select COUNT (Distinct reviewid) as dis_reviewcnt
from
(select A.reviewid from
bi.dpods_dp_reviewreport a left
outer join Bi.dpods_dp_reviewlog B on
a.reviewid=b
,c.nameFrom ORDERS O left OUTER joins CUSTOMERS C on c.id=o.customer_id and o.order_numberThe Results from statement 7 and statement 8 queries are clearly different, and the results shown in statement 8 are difficult to understand. Therefore, it is recommended that when writing a connection query, on is followed only by the join condition, and the conditions for
,o.customer_id,c.id,c.nameFrom ORDERS O left OUTER joins CUSTOMERS C on c.id=o.customer_id and o.order_number The Results from statement 7 and statement 8 queries are clearly different, and the results shown in statement 8 are difficult to understand. Therefore, it is recommended that when writing a connection query, on is followed only by the join condition, an
Statement 8: Place the WHERE condition in statement 7 behind on.SELECT O.id,o.order_number,o.customer_id,c.id,c.nameFrom ORDERS O left OUTER joins CUSTOMERS C on c.id=o.customer_id and o.order_number The Results from statement 7 and statement 8 queries are clearly different, and the results shown in statement 8 are difficult to understand. Therefore, it is recommended that when writing a connection query,
query from statement 7 and statement 8 are clearly different, and the result of statement 8 is incomprehensible. Therefore, it is recommended that when writing a connection query, on the following is only a join condition, while the conditions for the intermediate table restrictions are written to the WHERE clause. Statement 9: All outer joins (full OUTER
and statement 8 queries are clearly different, and the results shown in statement 8 are difficult to understand. Therefore, it is recommended that when writing a connection query, on is followed only by the join condition, and the conditions for the intermediate table restrictions are written in the WHERE clause. Statement 9: Full outer join (
different, and the results shown in statement 8 are difficult to understand. Therefore, it is recommended that when writing a connection query, on is followed only by the join condition, and the conditions for the intermediate table restrictions are written in the WHERE clause. Statement 9: Full outer join (OUTER
o.order_number The Results from statement 7 and statement 8 queries are clearly different, and the results shown in statement 8 are difficult to understand. Therefore, it is recommended that when writing a connection query, on is followed only by the join condition, and the conditions for the intermediate table restrictions are written in the WHERE clause. Statement 9: Full outer
in statement 8 are difficult to understand. Therefore, it is recommended that when writing a connection query, on is followed only by the join condition, and the conditions for the intermediate table restrictions are written in the WHERE clause. Statement 9: Full outer join (OUTER
statement 8 are difficult to understand. Therefore, it is recommended that when writing a connection query, on is followed only by the join condition, and the conditions for the intermediate table restrictions are written in the WHERE clause. Statement 9: Full outer join (OUTER
written in the WHERE clause. Statement 9: Full outer join (OUTER join). SELECT o.id,o.order_number,o.customer_id,c.id,c.name from ORDERS O OUTER joins CUSTOMERS C on C.id=o.custome r_id; Note: MySQL does not support all-out connections, and the notation given here is for
statement 8 queries are clearly different, and the results shown in statement 8 are difficult to understand. Therefore, it is recommended that when writing a connection query, on is followed only by the join condition, and the conditions for the intermediate table restrictions are written in the WHERE clause. Statement 9: Full outer join (
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.