473,408 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Last line in MYSQL table

I wrote a news script to post news posts in reverse chronological
order.

I'd like a page to post the last 6 posts from a page, from newest to
oldest.

But as it is, I don't know how to find the number of the last row in
the table. So I have to count down from 100, skipping blank entries
along the way.

Is there a simple way to find what how many rows are in a mysql table?
Jul 17 '05 #1
1 2172

"Nick" <fr*****@fresh27.net> wrote in message
news:86**************************@posting.google.c om...
I wrote a news script to post news posts in reverse chronological
order.

I'd like a page to post the last 6 posts from a page, from newest to
oldest.

But as it is, I don't know how to find the number of the last row in
the table. So I have to count down from 100, skipping blank entries
along the way.

Is there a simple way to find what how many rows are in a mysql table?


Flip your table around by adding "ORDER BY date_added DESC" to make the last
entries come to the 'front' and adding "LIMIT 6" to your query which will
give you the first 6 entries.

"SELECT * FROM news_articles (WHERE <if any where statements are needed>)
ORDER BY date_added DESC LIMIT 6"

I think that is what your are trying to do.

William
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Carlos Marangon | last post by:
Hello! I need some help. How can I recall the last 5 rows from a MySQL table and show them? Where is the FAQs of this newsgroup? Sincerely,
3
by: josh dismukes | last post by:
/// here is the code i'm getting a parse error on the last line of the code which /// is </html> any help will be much appreciated. <?php session_start ();
0
by: Morten Gulbrandsen | last post by:
USE company; DROP TABLE IF EXISTS EMPLOYEE; CREATE TABLE EMPLOYEE ( # PK SSN CHAR(9) NOT NULL, # FK SUPERSSN CHAR(9), DNO INT NOT NULL DEFAULT 1, CONSTRAINT EMPPK
8
by: Shawn McKenzie | last post by:
Can someone help me with a query to get the date/time that a database was last modified? I looked at the SHOW command but there was no mention of this. TIA, Shawn
3
by: bjam | last post by:
Hi, I am hoping someone can help with this I am assuming it is pretty basic but I don't see anything that jumps out at me at how to do this. Is there a way to have all the items output from the...
4
by: Neeper | last post by:
Hi, I've got a transactions table with a tstamp field (datetime type) and I need help creating a SELECT query to retrieve only last transactions that occured within the last 5 minutes. The...
4
by: Ike | last post by:
Is there a way in mysql to discern when the last date/time a field, row, or table was been updated or inserted? Thanks, ike
3
by: cdelarte | last post by:
I would like to be able to mail merge records from multiple mysql tables using a simple template, preferably via a command line script. MSWord mail merge via ODBC will not work for me as it only...
1
by: mosesdinakaran | last post by:
Hi All, How to find out the last accessed date of a MySql Database. I have around 200 databases in my server some are used and some are not in Use, I want to remove the database that are not...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.