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
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
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
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