Skip to main content
Participant
October 4, 2010
Question

php/MySQL Repeated region which doen't include the last item?

  • October 4, 2010
  • 1 reply
  • 518 views

Hi,

I hope somebody can help me with this. I use php/MySQL.
I need t create a repeated region which doen't include the last item (post) added to the table.

Does somebody know how to establish this?

This topic has been closed for replies.

1 reply

Participating Frequently
October 5, 2010

In SQL, there is no native concept of the last item inserted. It's up to you to control that. What is your definition of the last item? Is it the row with the greatest datetime stamp? An autoincrement id field? Something else?

Using an autoincrement id field as an example, the last row inserted will have the largest value, so

Select * from MyTable where MyID != (select max MyID from MyTable)

Participant
October 5, 2010

Thanks Bregent,

I use an autoincrement id field so your example is very helpful.

Participating Frequently
October 5, 2010

Great. I just noticed a few typos in my SQL but you get the idea.