sqlmysqlphpmyadmin

How to SELECT the last 10 rows of an SQL table which has no ID field?


I have an MySQL table with 25000 rows.

This is an imported CSV file so I want to look at the last ten rows to make sure it imported everything.

However, since there is no ID column, I can't say:

SELECT * FROM big_table ORDER BY id DESC

What SQL statement would show me the last 10 rows of this table?

The structure of the table is simply this:

columns are: A, B, C, D, ..., AA, AB, AC, ... (like Excel)
all fields are of type TEXT

Solution

  • 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.

    EDIT: you say

    ...to make sure it imported everything.

    What's wrong with using row count?