Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

New Here ,
Oct 04, 2010 Oct 04, 2010

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?

TOPICS
Server side applications
520
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 04, 2010 Oct 04, 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)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 05, 2010 Oct 05, 2010

Thanks Bregent,

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 05, 2010 Oct 05, 2010
LATEST

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


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines