Hirdesh
Hirdesh

Reputation: 163

i want to fetch all record from my database table without recent added record

i want to fetch all record from MySQL database table using PHP without last added record

I have 4 Columns in the Table, ID(auto) & title and message.

Upvotes: 1

Views: 55

Answers (1)

vaso123
vaso123

Reputation: 12391

You can use this, if as you say, ID is auto_increment

$sql = "SELECT * FROM table WHERE ID != (SELECT MAX(ID) FROM TABLE) ORDER BY ID";

This is selecting all the records from your table, ordered by id, where the id is not the biggest one.

Upvotes: 2

Related Questions