locked
Inner Join RRS feed

  • Question

  • User-1499457942 posted

    Hi

      Can we use Inner join in below statement

    SqlCommand sqlCommand = new SqlCommand("Select * from [Test] where  Category = @Category", con);
    sqlCommand.Parameters.AddWithValue("@category", ddlCategory.SelectedValue.ToString());

    Thanks

    Thursday, September 13, 2018 4:47 PM

All replies

  • User1120430333 posted

    Yes you can use a Select with an inner join with what you are showing. 

    Thursday, September 13, 2018 6:40 PM
  • User-893317190 posted

    Hi JagjitSingh,

    Yes , we could use inner join in ado.net.

    When we want to retrieve data from two related tables , we usually consider inner join.

    Do  you have two tables?Or you only have one table?

    If you only have one table we usually don't consider inner join  unless you want to self join.(refer to https://www.w3resource.com/sql/joins/perform-a-self-join.php)

    Below is a sample using inner join. 

    select * from categories c inner join products p on c.CategoryID=p.CategoryID where  p.CategoryID=@categoryId

    For more information about inner join, you could refer to https://www.w3resource.com/sql/joins/perform-an-inner-join.php

    Best regards,

    Ackerly Xu

    Friday, September 14, 2018 2:54 AM