I have a PHP script that adds data into my SQL table:
INSERT INTO user_data (first_name, last_name, email)
VALUES ('$first_name', '$last_name', '$email')
However, doing this inserts the data "backwards" into the table (i.e. the first entry will be the last in the table). Is there a way to insert the data into the last position of the given table?
Database tables do not have an inherit order. When you query a table without explicitly specifying an order by
clause there's no guarantee on the returned order, so there's no concept of data being inserted in a certain order or not - just explicitly specify what order you want it selected.
You cannot specify at which position your records get written. You may do an order by
in the select statement, and you may use myismchk
with option --sort-records
to do the ordering afterwards.