About encountered a "specified number of inquiries line" sql query problem today, suddenly found not previously been exposed how, just think of it, quickly looked at the document, and Internet search under, with the following things, I do not know if I have something wrong?
oracle:
a look at the documentation regarding any and all examples, very good oh.
Any
examples:
the SELECT * from emp the WHERE SAL> the ANY (SAL from the SELECT emp the WHERE deptno = 30) and deptno <> 30;
- to identify employees in other sectors of higher than 30 employees minimum wage = deptno
ALL
the SELECT * from emp SAL the WHERE> ALL (SAL from the SELECT emp the WHERE deptno = 30) and deptno <> 30;
- to identify employees in other sectors of high-wage employees the highest ratio deptno = 30
data queries specified row
SELECT <field list> from <table_name> WHERE rOWNUM <line number;
example:
SELECT * from EMP WHERE rownum <= 10; - 10 rows before the query
Note rOWNUM can not only be a write select * from emp where rownum between 20 and 30;
to check the first few lines of data can use the following methods:
SELECT * from EMP WHERE rownum <= Not EMPNO. 3 and in (SELECT from EMP WHERE EMPNO
rownum <= 3);
the results can return the entire data of the line 4-6;
however, the performance of this method is not high; if there are other good way, please tell me. (This is the document)
(database used to do a bit today, only to find self-righteous before the first rownum <= 3 to change the rownum <= 6 is wrong, this query means: find than before the first three lines of data in the three rows, i.e., each row of data 4-6, 3-6 instead of the original row.
Likewise lines 11-20 the following query:
SELECT * WHERE rownum from table_name <not in ID = 10 and ( WHERE rownum from table_name ID SELECT <= 10)
)
MySQL:
the lIMIT clause can be used to limit the number of rows returned SELECT statement. LIMIT takes one or two numeric arguments, the argument must
be non-negative integer constant (except when using the prepared statements).
When using two arguments, a first argument specifies the offset of the first row is returned, the second argument specifies the maximum number of rows to return
a large value. Initial line offset is 0 (not. 1):
MySQL> the SELECT * the FROM TBL the LIMIT 5,10; # Retrieve rows 6-15
for compatibility with PostgreSQL, MySQL also supports the LIMIT row_count OFFSET offset syntax.
If you want to restore all the rows between the end of the collection from a certain offset to the results, you can second parameter is the use of relatively large
numbers. This statement can recover all rows from the 96th row to the last:
mysql> SELECT * FROM tbl LIMIT 95,18446744073709551615 ;
using an argument that specifies the number of rows returned value from the beginning of the result set:
MySQL> the SELECT * the FROM TBL the LIMIT. 5; # Retrieve rows. 5 First
In other words, the LIMIT and n LIMIT 0, n equivalents.
For the prepared statement, you can use the position to maintain character. The following statement will return one row tb1 table:
MySQL> the SET @ A = 1;
MySQL> PREPARE STMT the FROM "the SELECT * the FROM tbl LIMIT?";
MySQL> EXECUTE STMT the USING @a;
The following statement returns the second from tb1 table the sixth line:
MySQL> Skip the SET @ = 1; numRows the SET @ = 5;
MySQL> PREPARE STMT the FROM "the FROM tbl LIMIT the SELECT *,??";
MySQL> EXECUTE STMT the USING @skip, @numrows;
sqlserver
I am asking for a data table with 1020 rows, how should inquire acridine, ID column is not continuous.
select top 20 * from table where id not in (select top 10 id from table name)


Take m to n statement records


1.
select   top   m   *   from   tablename   where   id   not   in   (select   top   n
*   from   tablename)


2.
SELECT * INTO top m temporary table (or table variable) from TableName Order by
ColumnName - lead into the top m
SET rowCount n-
SELECT * from Table variable order by columnname desc


3.
select   top   n   *   from
(select   top   m   *   from   tablename   order   by   columnname)   a
order   by   columnname   desc


4. If there are no other identity tablename column, then:
SELECT identity (int) ID0, * from tablename INTO #temp
take n and m is the statement:
SELECT * WHERE ID0 from #temp> and ID0 = n <= m
if you execute select identity (int) id0, * into #temp from tablename this statement
when an error, it is because you are in the middle of DB select into / bulkcopy attribute is not open must be executed:
Exec sp_dboption your DB name, " select into / bulkcopy ", true


5. If there is identity attribute table, simple:
SELECT * from TableName WHERE BETWEEN IDENTITYCOL and n-m

Product is slightly Library http://www.pinlue.com/