-1

I am using this sql statement to join two tables together where the return_date in one table is null.

SELECT 
    Customers.CustomerID, Customers.First_Name, 
    Customers.Surname, Customers.House_No, 
    Customers.Street, Customers.County, Customers.Postcode, 
    IssueBook.Return_Date 
FROM 
    Customers 
INNER JOIN 
    IssueBook ON Customers.CustomerID = IssueBook.CustomerID 
WHERE
    ((IssueBook.Return_Date IS NOT Null));

This statement is then used to fill a datagrid on a form. However when I view the datagrid they're could be duplicated rows as the customer may have taken more than one book out( just so you know I'm creating a library system). This means there is duplicated data. I know I can do a SELECT DISTINCT statement and delete the other rows and put the DISTINCT rows back in but I'm not sure how to do this as can I use a DISTINCT statement on the datagrid or will it have to be on the INNER JOIN sql statement? Please help?

dodexahedron
  • 4,584
  • 1
  • 25
  • 37

1 Answers1

0

Just put DISTINCT in the SQL query right next to the SELECT. You should have no problems as the DataGridView is GUI object from .NET and is completely independent from the database. It can show any tabular data you provide to it, whether it contains duplicates or not.

SELECT DISTINCT
Customers.CustomerID, Customers.First_Name, 
...
dimm
  • 1,792
  • 11
  • 15