Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2003
    Location
    New York
    Posts
    160

    Unanswered: Selecting a specific row from SQL ?

    im in vb
    doing a select statement
    im trying to pull a specific row "where row = ... " as apposed to do a "where something = something" from a field

    anyway to do that

    basically im sending a selected itemindex from a combobox and that item number i am trying to pull from the db (access)

    thnx
    Beyond Limitation

  2. #2
    Join Date
    Jan 2003
    Location
    Midwest
    Posts
    138
    SELECT * FROM tablename WHERE fieldname = datawanted

  3. #3
    Join Date
    Jan 2003
    Location
    New York
    Posts
    160
    that gets the row(s) of any nubmer
    im looking for example
    select row 5 from table
    a specifc row
    Beyond Limitation

  4. #4
    Join Date
    Nov 2002
    Location
    San Francisco
    Posts
    251
    OK,

    the basic DB model is based on IDs, each lookup table has next to field DESCRIPTION, ... also field ID, which is usually (not all the time) automatically assigned - MS Access calles it AUTONUMBER, MS SQL server IDENTITY. This number is UNIQUE and usually should have an index. Then the main table has column with that ID and links those two tables together using that ID. Just to clear misunderstanding - you HAVE TO DEFINE THIS FIELD!

    so for example:


    TABLE: CUSTOMER

    CustomerID unique accross table, should have index
    CustomerName
    Customer Telephone
    ...

    TABLE: INVOICE

    InvoiceID unique accross table, should have index
    CustomerID it is not unique, should have index, points to Customer table
    InvoiceDate
    ...


    generally say you should use NUMBERS and not string as an IDs (you can of course use the string), but numbers are much much faster.


    so here you can see that you don't need any row number. And tobe honest, most of the databases DO NOT HAVE row numbers. MS Access does not have it at all. Oracle does, but it has really different purpose.



    then I can write a SQL

    this selects all invoices and customer names
    SELECT InvoiceID, InvoiceDate, CustomerName FROM
    INVOICE INNER JOIN CUSTOMER ON invoice.CustomerID = customer.customerid

    this selects all customers even if they have no invoices
    SELECT InvoiceID, InvoiceDate, CustomerName FROM
    INVOICE RIGHT JOIN CUSTOMER ON invoice.CustomerID = customer.customerid



    jiri
    Last edited by playernovis; 02-06-03 at 12:09.

Posting Permissions

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