locked
RETURN DISTINCT ROW IN SQL DATASET RRS feed

  • Question

  • User1909155429 posted

    I WANT TO FIND UNIQUE ROWS FROM MY TABLE.MY SQL STAEMENT IS AS FOLLOWS:

      Dim selectStatement As String _
                   = "SELECT DISTINCT Email, firstname,LastName, AddressLine1, City, County, PostalCode,InvoiceNumber,Delivery.UserID " _
                & "FROM Delivery join Invoices on Delivery.UserID=Invoices.UserID " _
                  & "WHERE (firstname LIKE @firstname)AND (LastName LIKE @LastName)"

    THIS DOES NOT RETURN UNIQUE ROWS SO I TEND TO USE LINQ METHOD TO REMOVE DUPLICATE. BUT I AM SURE IT CAN BE

    FOUND DIRECT FROM TABLE?

    Thursday, November 26, 2020 6:44 PM

All replies

  • User303363814 posted

    THIS DOES NOT RETURN UNIQUE ROWS
    Can you show an actual query and the actual results where you are seeing this?

    Friday, November 27, 2020 1:10 AM
  • User-939850651 posted

    Hi peterthegreat,

    According to the query statement you provided, I think the reason why you did not get the expected result may be:

     Dim selectStatement As String _
                   = "SELECT DISTINCT Email, firstname,LastName, AddressLine1, City, County, PostalCode,InvoiceNumber,Delivery.UserID " _
                & "FROM Delivery join Invoices on Delivery.UserID=Invoices.UserID " _
                  & "WHERE (firstname LIKE @firstname) AND (LastName LIKE @LastName)"

    You used fuzzy query in the query statement, I am not sure if you understand its effect. 

    I am wondering whether the conditions should be:

    WHERE (firstname = @firstname) AND (LastName = @LastName)

    If I misunderstood something, could you provide more details?

    Best regards,

    Xudong Peng

    Friday, November 27, 2020 6:38 AM