Mysql Query

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Zeeshan

    Mysql Query

    Hi everybody,

    How can I get rownum using MySQL queries ,
    In Oracle one can you in this way SELECT rownum as srno, fname FROM
    tablename
    suppose If there are 45 records and if i use while for the

    srno should display 1, 2, 3, ... 45

    query like SELECT rownum as srno, fname FROM tablename

    I dont want to use php counter, i want it from query

    Reagrds
    Friend

  • Berimor

    #2
    Re: Mysql Query

    On Wed, 02 Nov 2005 12:50:10 +0200, Zeeshan <zeeshan359@gma il.com> wrote:
    [color=blue]
    > Hi everybody,
    >
    > How can I get rownum using MySQL queries ,
    > In Oracle one can you in this way SELECT rownum as srno, fname FROM[/color]

    $sql=mysql_quer ry(SELECT COUNT(*) FROM table_name WHERE condition);
    $res=mysql_fetc h_row($sql);
    $numofrows=$res[0];

    [color=blue]
    > tablename
    > suppose If there are 45 records and if i use while for the
    >
    > srno should display 1, 2, 3, ... 45
    >
    > query like SELECT rownum as srno, fname FROM tablename
    >
    > I dont want to use php counter, i want it from query
    >
    > Reagrds
    > Friend
    >[/color]



    --
    ---
    Exact Meta Search | Major Search Engine

    Comment

    • Berimor

      #3
      Re: Mysql Query

      On Wed, 02 Nov 2005 14:23:51 +0200, Berimor <roman@roman.ro man> wrote:
      [color=blue]
      > On Wed, 02 Nov 2005 12:50:10 +0200, Zeeshan <zeeshan359@gma il.com> wrote:
      >[color=green]
      >> Hi everybody,
      >>
      >> How can I get rownum using MySQL queries ,
      >> In Oracle one can you in this way SELECT rownum as srno, fname FROM[/color]
      >
      > $sql=mysql_quer ry(SELECT COUNT(*) FROM table_name WHERE condition);[/color]

      sorry $sql=mysql_quer y("SELECT COUNT(*) FROM table_name WHERE
      condition"); :)
      [color=blue]
      > $res=mysql_fetc h_row($sql);
      > $numofrows=$res[0];
      >
      >[color=green]
      >> tablename
      >> suppose If there are 45 records and if i use while for the
      >>
      >> srno should display 1, 2, 3, ... 45
      >>
      >> query like SELECT rownum as srno, fname FROM tablename
      >>
      >> I dont want to use php counter, i want it from query
      >>
      >> Reagrds
      >> Friend
      >>[/color]
      >
      >
      >[/color]



      --
      ---
      Exact Meta Search | Major Search Engine

      Comment

      • Ewoud Dronkert

        #4
        Re: Mysql Query

        Zeeshan wrote:[color=blue]
        > Hi everybody,[/color]

        Better asked in comp.databases. mysql

        --
        E. Dronkert

        Comment

        Working...