In many basic table-based queries, to meet one condition, you often need to join another table. In this case, using EXISTS (or not exists) usually improves the query efficiency. IN a subquery, the not in Clause executes an internal sorting and merging. IN either case, not in is the most inefficient (because it executes a full table traversal for the table IN the subquery ). To avoid using not in, we can rew
Determine whether data exists
If exists (select * From hong_pageconfig where names = 'name') Begin print '1' endelse begin print '0' end
----------------- Determine whether the table name to be created existsIf exists (select * From DBO. sysobjects where id = object_id (n'[DBO]. [Table name] ') and objectproperty (ID, N 'isusertable') = 1)-- Delete a tableDrop
$file = ' jbxue.com.php ';
if (is_readable ($file) = = False) {
Die (' file does not exist or cannot be read ');
} else {
echo ' presence ';
}
?>
Copy CodeThe is_readable () function determines whether the specified file name is readable. Returns TRUE if the specified file or directory exists and is readableExample 2:
$filename = ' jbxue.com.php ';
if (file_
Exists and no existsHttp://hi.baidu.com/yds_amber/blog/item/0f64cfcf2c91b13bf8dc61d2.html
Select *From a left join B on A. ID = B. Id2Where not exists (select 1 from B B1 where B. Id2 = b1.id2 and B. XH> b1.xh)
Is not in this range.Select IDFrom tableWhere name not exists (select 1From tableWhere name = 'aaa ')You may not understand the meaning of this 1. Howev
If the directory is available:
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->DirectoryInfo TheFolder = new DirectoryInfo (PathName );
If (TheFolder. Exists)
{
//.............
}
If the file is available:
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->FileInfo TheFile = new FileInfo (PathName );
If (TheFile. Exis
Tags: conditional log ACL using IMG Compare GPO not RACThe most basic difference:
In using indexes on the primary table
exists using indexes on child tables
Not in does not use an index
Not exists use indexes on master tables
Writing:
The Where condition of the exist is: "... where exist (.... where a.id=b.id)"
In the Where condition is: "... where ID in (SELECT ID .... where a.id=
1; First, the use of in/not inIn/not in is to determine whether the value of a single property matches the value of a given value or subquery; SELECT * from Student s where s.id in (n/a); SELECT * from Proj_basic_info P where not exists (SELECT * from Proj_basic_info Q where p.id=q.id and q.proj_t Ype=1 and q.qy_source= ' Suaee ') Summary: If you are judging whether a single property is a match, select In/not in; If you are judging multi
JS: a simple method for determining whether a function exists. js judges whether a function exists.
This article describes how to determine whether a function exists in JavaScript. We will share this with you for your reference. The details are as follows:
Run the following command:
Tags: Teacher mat drop format schema style ... sql postLi Wu:Heng Learn to think together, honouring teachers save Thanksgiving. Leaf See root three return to one, rivers the same oneness.Meekness Conscience Lord, willing to do without regrets to the most bitter. Reading exercises to keep the body and mind, sincere advice and the line and cherish.
Data,
data, Lingen on the data. You must be cautious about operating the database. Give the most bitter code here, and take a look at it, t
from the point of view of efficiency:
1 SELECT * from T1 where exists (select 1 from T2 where t1.a=t2.a);
When the amount of T1 data is small and the T2 data is very large, the query efficiency of the T1
2) SELECT * from T1 where t1.a in (select t2.a from T2);
T1 data volume is very large and T2 data hours, T1>>T2, 2 of the query efficiency is high.
In short, General: the appearance is big, use in, inside table is big, use
EXISTS (SQL returns the result set as true)Not EXISTS (SQL does not return result set is true)As follows:Table AID NAME1 A12 A23 A3Table BID AID NAME1 1 B12 2 B23 2 B3Table A and table B are 1-to-many relationships a.id = B.aidSelect Id,name from A where EXIST (SELECT * from B where a.id=b.aid)Execution results are1 A12 A2The reasons can be analyzed as followsSelect Id,name from A where
Tags: do not repeat nbsp htm www other art max repeat data maxUse of exists,not exists in a go SQL Exists: The emphasis is on whether to return the result set and not to know what to return, such as:Select name from student where sex = ' m ' and mark exists (select 1 from grade where ...), as long asExists the BOOT cl
Label: exists is used to check if a subquery returns at least one row of data, and the subquery does not actually return any data, but instead returns a value of TRUE or FalseEXISTS Specifies a subquery that detects the existence of a row. Instance: (i). Using NULL in a subquery still returns the result set Select * from where exists (selectnull)
Select * from Tablein Query results (b). Compa
Exists: The emphasis is on whether to return the result set and not to know what to return, such as:Select name from student where sex = ' m ' and mark exists (select 1 from grade where ...), as long asExists the BOOT clause has a result set return, then exists this condition is set up, we notice that the returned field is always 1, if you change to "Select 2 fro
Tags: back 16px technology sharing BSP student SED join technology start A subquery with the EXISTS operator does not return any data, producing only logical truth ' true ' or logical false value ' false '. Subqueries with the EXISTS operator are correlated subqueries. Correlated subqueries: The conditions of a subquery depend on the parent query. EXISTS: If the
Tags: scan val div span copy size src insert where1, in and exists In is the appearance and the inner table as a hash connection, and exists is the external loop loop, each loop loop and then query the internal table, has always been considered exists than in the high efficiency of the argument is inaccurate. If the query of two table size is equal, then with in
Tags: table div sts exist col useful where int query statement1, in and exists
In is the appearance and the inner table as a hash connection ;
The exists is a loop loop for appearances , and each loop is then queried on the internal table ;
The assertion that exists is more efficient than in is inaccurate.
If the size of the two tabl
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.