Results 1 to 4 of 4

Thread: Sql Query Question

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2004
    Location
    in the heart of the Mediterranean
    Posts
    1,143

    Sql Query Question

    Hi,

    I have 3 tables from which I need to access this information. Tables are: HARDWARE & EQUIPMENT_INFO & LEGER:

    Hardware Fields are:

    Serial No
    Equip_Code
    SchoolID
    Schooltype
    Make
    Model

    Equipment_Info Fields are:

    Equip_Name
    Equip_Code

    LEGER Fields are:

    File No
    Serial no
    Supplier
    Value

    The user will have a listbox that displays the Equip_name.On clicking the selection I need to make a connection query on the Access Database.


    I need to
    SELECT * FROM HARDWARE WHERE SCHOOLTYPE = P AND WHERE LISTBOX1.selection = ((INNER join HARDWARE AND EQUIP_INFO WHERE Serial No: S.No) and (INNER join LEGER AND EQUIPMENT_INFO WHERE Inventory_no = Equip_Code))

    Never done a detailed query. Can someone tell me If I have the right code for the query. Thanks for your help

  2. #2
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961

    Re: Sql Query Question

    Which Is The Foreign Key Of Leger Table? Could You Please Give Me Relationship Details Of These Three Tables?

  3. #3
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961

    Re: Sql Query Question

    I think this could help

    VB Code:
    1. strSQL = "SELECT Hardware.*, Equipment_Info.*, Leger.* from Hardware, Equipment_Info, Leger where Equipment_Info.Equip_Code = Hardware.Equip_Code and Leger.[Serial No] = Hardware.[Serial No] and SCHOOLTYPE = 'P'"

    Regards

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2004
    Location
    in the heart of the Mediterranean
    Posts
    1,143

    Re: Sql Query Question

    Hi pvbangera ,

    Thanks very much for comng in to help me. Guess rather stupid of me not to include the foreign keys and primary keys. Maybe this will change the query you had sent me. one other thing does the Table.Field in the SQL can be used as code in the VB.NET sqlstring.Then I need to make the Listbox.Selected.Item to the query

    Only just starting doing ADO.NET so dont mind me if its an elementary question. Thanks once again for helping me.

    The foreign and primary keys are these:

    Hardware foreign key is SerialNo (I also have Equip_Code field which is a foreign key here, but I dont know whether this is redundant since it is repeated in the Leger Table

    Leger primary key is SerialNo and foreign key is Equip_Code

    Equip_Info has Equip_Code as a primary key.
    Last edited by angelica; Mar 4th, 2005 at 10:19 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width