hi i have this mysql statement without limit so it will get first row in ascending order but i want to get the title of second row as well
$res = mysql_query("select * from tas where id='{$m_id}' ");
after that i can fetch and get the first output without any issue earlier i was required to get the id so i used this
$nidf=$m_id-1;
but now i need title of previous id.table consists if id,title,views etc .i know it can be done easily by this query
$res2 = mysql_query("select * from tas where id='{$nidf}' ");
but i dont want to execute second syl query and i want to learn how it can be done without using above query
i cant not use while as i need only second title and rest of the thigs i need for first row only
SELECT *
FROM tas
WHERE id <= $m_id
ORDER BY id DESC
LIMIT 2
fetch all the rows that have your specified ID OR* LESS, order by that id in descending order, then return only the first 2 rows in that ordered set. That'll be the $m_id you wanted, and the next immediately lower id as well.