Limiting MySQL output
Posted: Thu Jun 27, 2002 12:23 pm
Hi all!,
I am trying to set-up a news page on my site which
a) only lists the 10 most recent entries
b) writes the first sentance/100 characters of each story with a "more" button to expand the story.
I have the news articles in a db with auto_increment id numbers, which is then sorted in descending order to give the most recent story first. However, does not work (it does in Access, so the syntax seems correct!) I am using MySQL 3.23.49, hosted be a company, so no upgrade suggestions!.
I wanted MySQL to limit the size of the story, because if a user then reads the article, the whole lot would need to be parsed twice and I guess in PHP this is not efficient.
If any one can help with either of these problems I would be greatful.
I am trying to set-up a news page on my site which
a) only lists the 10 most recent entries
b) writes the first sentance/100 characters of each story with a "more" button to expand the story.
I have the news articles in a db with auto_increment id numbers, which is then sorted in descending order to give the most recent story first. However,
Code: Select all
SELECT TOP 10 story FROM newsI wanted MySQL to limit the size of the story, because if a user then reads the article, the whole lot would need to be parsed twice and I guess in PHP this is not efficient.
If any one can help with either of these problems I would be greatful.