mysql数据库查询显示,如何查看倒数第三行数据,就只是一行,其他的都不要?谢谢

解决方案 »

  1.   

    SELECT * FROM tablename ORDER BY id DESC LIMIT 2, 1
    // id是主键递增,按倒序排列。LIMIT 2,1 取第3条数据
      

  2.   

    $sqlhot="select * from news where ntype='2' order by nid desc";
    你看哈应该怎么改,才能去除倒数第二、第三、第四,
    还有里面有一个字段是ndate的,要怎么样才可以只取出nadate里面的‘天’月和年都不要,然后取出‘月’天和年不要,但是‘月’的要变成英文,怎么搞?谢谢
      

  3.   

    $sqlhot="select * from news where ntype='2' order by nid desc";
    你看哈应该怎么改,才能取出倒数第二、第三、第四,
    还有里面有一个字段是ndate的,要怎么样才可以只取出nadate里面的‘天’月和年都不要,然后取出‘月’天和年不要,但是‘月’的要变成英文,怎么搞?谢谢
      

  4.   

    $sqlhot="select .....,day(nadate),monthname(nadate) from news where ntype='2' order by nid desc limit 1,3";
      

  5.   

    $sqlhot="select .....,day(nadate),monthname(nadate) from news where ntype='2' order by nid desc limit 1,3";
    怎么得到天和月,然后再怎么输出?
      

  6.   

    $sqlhot="select .....,day(nadate),monthname(nadate) from news where ntype='2' order by nid desc limit 1,3";
     $rs=$obj->fetchrow($sqlhot1);
     $ndate=$rs->ndate; 
     这样写获得对不?
     然后输出是   <?=$ndate('d');?>
     但是这样好像不对啊?出错啦!
      

  7.   

    汗......那省略号是举个例子。你要取几个字段就写几个。另外。不知道你的$obj->fetchrow是怎么写的。因为有三条。肯定要while循环的。
      

  8.   

    $sqlhot="select nid,ntitle,ntype,day(ndate),monthname(nadate) from news where ntype='2' order by nid desc";
        $rs=$obj->fetchrow($sqlhot);
        $nid=$rs->nid;
        $ntitle=$rs->ntitle;
        $nword=$rs->nword;
        $ndate=$rs->ndate;
        $ntype=$rs->ntype;
    这样你看对不?但是我不知道怎么取得day(ndate),monthname(nadate),先不循环,这样我看懂点,慢慢来,谢谢啊!
      

  9.   

    哦。我明白你的意思了。取个别名。
    $sqlhot="select nid,ntitle,ntype,day(ndate) as d,monthname(nadate) as m from news where ntype='2' order by nid desc";取时: 
    .........
    $ntype=$rs->d;
    $ntype=$rs->m;
      

  10.   

    $sqlhot="select nid,ntitle,ntype,day(ndate) as d,monthname(nadate) as m from news where ntype='2' order by nid desc";
        $rs=$obj->fetchrow($sqlhot);
        $nid=$rs->nid;
    $ntitle=$rs->ntitle;
    $nword=$rs->nword;
    $ndate=$rs->ndate;
    $ntype=$rs->ntype;
    $month=$rs->m;
    $day=$rs->d;
    这样写你看对吗?但是出现了这样的错误
    mysql Error: 1054
    select nid,ntitle,ntype,day(ndate) as d,monthname(nadate) as m from news where ntype='2' order by nid desc
      

  11.   

    他就提示是这样的
    mysql Error: 1054
    select nid,ntitle,ntype,day(ndate) as d,monthname(nadate) as m from news where ntype='2' order by nid desc
    然后什么都没有
      

  12.   

    表名:news
    字段: nid、ntitle、ntype、ndate
    就这么多然后就要查看所有的,可是ndate是自己写的时间2012-03-25,现在要显示2012-03-25的25,还有2012-03-25的月份03,但是03要变成大写的mat,这样你看应该这么写代码?谢谢啊。