How to SELECT the last 10 rows of an SQL table which has no ID field?(如何选择没有 ID 字段的 SQL 表的最后 10 行?)
问题描述
我有一个包含 25000 行的 MySQL 表.
I have an MySQL table with 25000 rows.
这是一个导入的 CSV 文件,所以我想查看最后十行以确保它导入了所有内容.
This is an imported CSV file so I want to look at the last ten rows to make sure it imported everything.
但是,因为没有ID栏,所以不能说:
However, since there is no ID column, I can't say:
SELECT * FROM big_table ORDER BY id DESC
哪个 SQL 语句会显示该表的最后 10 行?
表格的结构很简单:
columns are: A, B, C, D, ..., AA, AB, AC, ... (like Excel)
all fields are of type TEXT
推荐答案
SQL 表没有隐式排序,排序必须来自数据.也许您应该向表中添加一个字段(例如一个 int 计数器)并重新导入数据.
SQL tables have no implicit ordering, the order has to come from the data. Perhaps you should add a field to your table (e.g. an int counter) and re-import the data.
然而,这只会给出导入的顺序,而不是数据.如果您的数据没有排序,您必须了解如何添加它.
However that will only give the order of the import and not the data. If your data has no ordering you have to find out how to add it.
你说
...以确保它导入了所有内容.
...to make sure it imported everything.
使用行数有什么问题?
这篇关于如何选择没有 ID 字段的 SQL 表的最后 10 行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何选择没有 ID 字段的 SQL 表的最后 10 行?


基础教程推荐
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01