autonumber in query


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: autonumber in query

  1. #1
    johnny Guest

    autonumber in query


    I want to have an autonumber type field in a query for Access. An example:

    Lets say I have a table with 100 records. I want to select five records
    anywhere within the table and have a return that looks like the following:

    ID r1 r2 ... rn
    1 ......
    2 ......
    3 ......
    4 ......
    5 ......

    Obviously I don't care about the dots, those are meant to be substitutes
    for the actual values that I would receive. The important aspect of this
    is to have an ID field (which doesn't exist in the table) that acts like
    an autonumber in a query.

  2. #2
    helena Guest

    Re: autonumber in query


    The field data type must be set to AutoNumber

    "johnny" <johnny@nospam.com> wrote:
    >
    > I want to have an autonumber type field in a query for Access. An example:
    >
    >Lets say I have a table with 100 records. I want to select five records
    >anywhere within the table and have a return that looks like the following:
    >
    >ID r1 r2 ... rn
    >1 ......
    >2 ......
    >3 ......
    >4 ......
    >5 ......
    >
    >Obviously I don't care about the dots, those are meant to be substitutes
    >for the actual values that I would receive. The important aspect of this
    >is to have an ID field (which doesn't exist in the table) that acts like
    >an autonumber in a query.



  3. #3
    johnny Guest

    Re: autonumber in query


    How? A further example:

    I have a table that has two fields: c1 and c2. Their data types don't matter...
    Then I want have a query which is similar to:
    SELECT Identity(1,1) as ID, c1, c2 FROM table WHERE c1 > 4
    Thus the results would look something similar to:
    ID c1 c2
    1 5 6
    2 6 12
    3 7 3
    4 8 234
    .. .. ..
    n .......


    "helena" <helenabarata@hotmail.com> wrote:
    >
    >The field data type must be set to AutoNumber
    >
    >"johnny" <johnny@nospam.com> wrote:
    >>
    >> I want to have an autonumber type field in a query for Access. An example:
    >>
    >>Lets say I have a table with 100 records. I want to select five records
    >>anywhere within the table and have a return that looks like the following:
    >>
    >>ID r1 r2 ... rn
    >>1 ......
    >>2 ......
    >>3 ......
    >>4 ......
    >>5 ......
    >>
    >>Obviously I don't care about the dots, those are meant to be substitutes
    >>for the actual values that I would receive. The important aspect of this
    >>is to have an ID field (which doesn't exist in the table) that acts like
    >>an autonumber in a query.

    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center