Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2003
    Posts
    11

    Red face Unanswered: about autonumber column in queries ..

    it is possible to generate a sql code to return a automatic incremental row number by an number specified up to number of rows returned (add the initial start number of course)?
    Eq.

    start to 5000
    ..5000
    ..5001
    ..5002
    .. etc
    something of

    select field1,..fieldn ,<row_number> + start_number from table ;

    please tell me if is not possible.... but not wih an auto_increment field from table
    i think the triky part is to generate row number.. to add a start number must be easy ( HA - )

  2. #2
    Join Date
    Oct 2003
    Location
    Denver, Colorado
    Posts
    137
    If you want to generate row numbers, you can use the following in your SELECT query:

    SET @rownumber = 0;
    SELECT @rownumber := @rownumber + 1 AS RowNumber, ...

    This will create row numbers starting at one, so if you want to start at another point, then just set @rownumber equal to one less than the starting point. If you want to return only part of the result set, then just use LIMIT at the end of your SELECT query. Like: "LIMIT 50, 5000" to start at 5000 and return only 50 rows.

  3. #3
    Join Date
    Nov 2003
    Posts
    11
    ole !!!!
    THANK-YOU

  4. #4
    Join Date
    Nov 2003
    Posts
    11
    SOMETHING IS WRONG !!!!
    THE SQL CODE YOU GIVE ME WORKS ON SERVER AND ON MYSQL CLIENT.
    IT JUST DON'T WORK UNDER SOMETHING ELSE
    I TRY IT UNDER ACCESS ON PASS THROUGH QUERYES AND IT IS SOMETHING ABOUT SINTAX WITH :=

  5. #5
    Join Date
    Oct 2003
    Location
    Denver, Colorado
    Posts
    137
    Using := is MySQL's way of assigning user variables in the SELECT syntax. Access uses JetSQL syntax. I am not sure exactly what you should do to remedy it. I am not even sure that user variables are allowed in Access (I am not an Access wiz). You might want to present this question in the Access forum.

    Originally posted by rusmnicolae
    SOMETHING IS WRONG !!!!
    THE SQL CODE YOU GIVE ME WORKS ON SERVER AND ON MYSQL CLIENT.
    IT JUST DON'T WORK UNDER SOMETHING ELSE
    I TRY IT UNDER ACCESS ON PASS THROUGH QUERYES AND IT IS SOMETHING ABOUT SINTAX WITH :=

  6. #6
    Join Date
    Nov 2003
    Posts
    11
    OK.THANK-YOU FOR YOUR SUGESTION.IWILL TRY IN THE ACCESS FORUM



    THANK-YOU AGAIN

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •