SQL Join on three or more tables
  • Hello
    I want to get data from 3 or more tables in SQL using c#. Please tell me what should i do. My tables are




    image


    I want to get following values
            item_id, Item_name, category from tbl_items
            project_id, project_name, Address form tbl_projects 
            Allocation_id, startDate and EndDate from Tbl_allocations where item_id and Project_is is equal to above tables.

    please suggest how can i do this,.
  • 2 Comments sorted by
  • Vote Up0Vote Down ithackerithacker
    117.50 Karma Accepted Answer
    your sql query will be like this.

    select * from tbl_Items
    Inner Join tbl_Projects on tbl_Items.Item_Id=tbl_Projects.Project_Id
    Inner Join tbl_Alloction on tbl_Items.Item_id=tbl_Allocation.Item_Id and Tbl_Projects.project_Id=tbl_Allocation.Project_Id

  • I hope It will help you
    select * from tbl_items
    Inner join tbl_Projects on tbl_Item.Item_Id=tbl_project.Item_id
    Inner join tbl_Allocation on tbl_items.Item_Id=tbl_Allocation.Item_id and tbl_Projects.Project_Id=tbl_Allocation.Project_Id

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Tagged

Popular Posts of the Week

    Optimum Creative