English 中文(简体)
反倒LQ所列结果的次序
原标题:Reverse the order of the result set in SQLite

这可能是一个非常基本的问题,但我根本不知道。

为了简化问题,请允许我提出一个只列一栏的表格,以便我能够横向地勾销:

1 3 11 39 41 45 52 63 66 70 72 80 81 90 92 97

As you can see, they are sorted. Now, I know there is the row with "70", and I want to query five rows before it in ascending order. That is, I want

41 45 52 63 66

我应该怎样做?

我可以质疑五行的降价,并扭转其后取得的成果,但我认为应该有更好的办法。

最佳回答

仅修改以下案文:

SELECT * FROM (
    SELECT *
    FROM SAMPLE
    WHERE index1 < 70
    ORDER BY index1 DESC
    LIMIT 0,5
)
ORDER BY index1 ASC;
问题回答

下面是我能够提出的询问,但我不清楚这是否是你所需要的,而且其结果是命令 des。

我设立了一个表,即SAMPLE,其唯一一个栏目是:

SELECT * FROM SAMPLE WHERE index1 < 70 ORDER BY index1 DESC LIMIT 0,5;




相关问题
sqlite3 is chopping/cutting/truncating my text columns

I have values being cut off and would like to display the full values. Sqlite3 -column -header locations.dbs " select n.namelist, f.state, t.state from names n left join locations l on l.id = n.id ...

Entity Framework with File-Based Database

I am in the process of developing a desktop application that needs a database. The application is currently targeted to SQL Express 2005 and works wonderfully. However, I m not crazy about having ...

Improve INSERT-per-second performance of SQLite

Optimizing SQLite is tricky. Bulk-insert performance of a C application can vary from 85 inserts per second to over 96,000 inserts per second! Background: We are using SQLite as part of a desktop ...

Metadata for columns in SQLite v2.8 (PHP5)

How can I get metadata / constraints (primary key and "null allowed" in particular) for each column in a SQLite v2.8 table using PHP5 (like mysql_fetch_field for MySql)? sqlite_fetch_column_types (OO:...

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签