1. for mysql data query, the size fields must be separated. This is still necessary unless you query the index content instead of the table content, for example, only the id is queried. the query speed is closely related to the index, that is, the
There is a tens of millions of-record table on MySQL 5.0.x, which now reads about 1 billion of the records. Common methods, followed by loops:
1
The code is as follows
Copy Code
SELECT * FROM mytable where index_col =
After repeated regions are added, you can add them in ascending order. if you want to add repeated regions on a webpage, 50 entries of information cannot be displayed in ascending order. The old information at the bottom of the page is at the top of
I finally decided to resign today. I took half a day off for an interview! When I was doing A pen test: I encountered an SQL statement to query 31st to 40 records in table A of the database. The table has an auto-incrementing field ID, and the id is
1. After testing, the following method is passed:
Select * from(Select Table name. *, rownum as con from table name where rownum )Where con> = N;
2. Refer to other online methods
SQL/Oracle Method for retrieving records from MB to
After several studies have written the following code, there is a need to refer to the following
Copy Code code as follows:
Kd=server. HTMLEncode (Request ("keyword"))
If kd<> "" Then
Kd=trim (KD)
' Kd=replace (KD, "", "")
Kd=replace (
1: First of allSelect Row_number () over (order by ID ASC) as ' RowNumber ', * from table1Generate a collection with an ordinal2: Re-query the 1th to 5th data of the collectionSELECT * FROM(select Row_number () over (order by ID ASC) as ' RowNumber '
Description: This example is a running environment with SQL Server 2005.Ready to work: Create a database named db (Create DB).One, T-SQL row to column1. Create the following tableCREATE TABLE [Scores] ([ID] INT identity (+),--Self-increment
1: First of allSelect Row_number () over (order by ID ASC) as ' RowNumber ', * from table1Generate a collection with an ordinal2: Re-query the 1th to 5th data of the collectionSELECT * FROM(select Row_number () over (order by ID ASC) as ' RowNumber '
3 Ways to paging SQL Server are as follows:
---SQL Server 2005-page statement collection
----Disadvantages:
Top: Complex SQL must be written by the user and no composite primary key is supported
Max: Users must write complex SQL and do not
Delete the first 100 data entries and sort them by the primary key ID. How to write SQL statements?
Delete from visitrecord where id in (select top 100 from visitrecord order by id asc)
Is there any error in this writing?
Reply to
Delete the first 100 data entries and sort them by the primary key ID. How to write SQL statements? Delete & nbsp; from & nbsp; visitrecord & nbsp; where & nbsp; id & nbsp; in & nbsp; (select & nbsp; top & nbsp; 100 & nbsp; from & nbsp; visitrecord &
ArticleDirectory
Use pseudo-column rownum
Use analysis functions
Use minus
Use pseudo-column rownum
Query the first 10 records
Select * From t_user t where rownum
Rank the first three records by student ID
Select * from
How do you write SQL statements?
Delete from Visitrecord where ID in (select top of Visitrecord ORDER by ID ASC)
Is there any mistake in writing this?
Reply to discussion (solution)
Delete from Visitrecord where ID in (select ID from
Feature: only one page of data is returned for a single query. Instead of getting all the data.
Note:
Pagesize: number of records displayed per page
Cureentpage: Current page number
Select * from (select top pagesize * cureentpage * From user_table
Take the first 20 to 30 in the query as an example, with the primary key named ID
Method One: Check first, then reverse check
Select Top * FROM (SELECT top * to tablename ORDER BY ID ASC) an ORDER by id DESC
Method Two: Use the LEFT Join
Algorithm | Random because of the need for teaching, I decided to write a asp+ms sql2000 online examination system, its function is mainly: to realize the judgment question, the single multiple-choice question and fill in the blank question on-line
Three ways to "SQL" Oracle Paging queriesUse pseudo-column rownum to query the first 10 records?
1234567891011
[sql] select * from t_user t where ROWNUM 按照学生ID排名,抓取前三条记录[java] SELECT * FROM(SELECT id,realname FROM T_USER ORDER BY id
Author: yanekEmail: yanek@126.com
Feature: only one page of data is returned for a single query. Instead of getting all the data.Note:
Pagesize: number of records displayed per pageCureentpage: Current page number
Select * from (select TOP
Take the first 20 to 30 queries as an example. The primary key name is ID.
Method 1: perform a regular check first and then perform a reverse check.Select top 10 * from (select top 30 * From tablename order by id asc) A order by ID DESC
Method 2:
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.