katie77 Posted November 19, 2007 Share Posted November 19, 2007 Hi there, I have a table containing News items grouped into different categories, like so: CategoryStory Date SportTeam wins match14Oct2007 SportTeam does not win match15Oct2007 SportFootball results16Oct2007 SportHockey player falls over01Nov2007 SportHooligans spoil match12Sep2007 BuinessBank collapses14Oct2007 BuinessCompany boss gets the sack24Oct2007 BuinessFTSE 10029Oct2007 BuinessManager found asleep under the table30Oct2007 BuinessTramp inherits world's biggest company19Nov2007 PoliticsPrime Minister trips over pavement15Oct2007 PoliticsPresident visits North Pole18Oct2007 From this table, I would like to create another table containing the 4 most recent stories in each category, where story1 is the most recent. It would look like this: Category Story1 Story2 Story3 Story4 SportHockey player falls overFootball resultsTeam does not win matchTeam wins match BuinessTramp inherits world's biggest companyManager found asleep under the tableFTSE 100Company boss gets the sack PoliticsPresident visits North PolePrime Minister trips over pavement[/td][td] Does anyone know how this could be done in SQL? Many thanks, Katie Quote Link to comment https://forums.phpfreaks.com/topic/77916-create-table-with-most-four-most-recent-items/ Share on other sites More sharing options...
victor_ar Posted November 21, 2007 Share Posted November 21, 2007 hi, could it be using PHP and SQL or only a sql query? Quote Link to comment https://forums.phpfreaks.com/topic/77916-create-table-with-most-four-most-recent-items/#findComment-395886 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.