selecting second last row

2007-05-30 Thread ross
I have a table of publications. -- Table structure for news -- CREATE TABLE `news` ( `id` int(100) NOT NULL auto_increment, `content` longblob, `title` varchar(100) default NULL, `date` date default NULL, `display` varchar(10) default 'no', PRIMARY KEY

Re: selecting second last row

2007-05-30 Thread Baron Schwartz
I have a table of publications. -- Table structure for news -- CREATE TABLE `news` ( `id` int(100) NOT NULL auto_increment, `content` longblob, `title` varchar(100) default NULL, `date` date default NULL, `display` varchar(10) default 'no', PRIMARY KEY

RE: selecting second last row

2007-05-30 Thread Edward Kay
SELECT * FROM news WHERE display='yes' ORDER BY id desc limit 1 Think this would get the lastest article that is to be displayed but how do I get the second one. Just add an offset to the LIMIT clause: SELECT * FROM news WHERE display='yes' ORDER BY id desc limit 1,1 Edward -- MySQL

selecting second last row

2007-05-30 Thread waldo_tumanut
If there are only two rows that satisfy SELECT * FROM news WHERE display='yes' ORDER BY id desc then SELECT * FROM news WHERE display='yes' ORDER BY id asc limit 1 gives the second row. Am I missing something? Waldo Tumanut Database Analyst