I have written this query in sql server 2005 but it still will show the name of products that are the same!!thanks
SELECT DISTINCT ProductName
FROM Products,Suppliers
WHERE Products.SupplierID = Suppliers.SupplierID AND Fax IS NULL
for example I have two product names that are the same ‘Chei’ instead of returning one ‘chei’ it will return both of them
What you have posted should work fine.
Is it possible you’re selecting other stuff like this?
Alternatively, you should be writing it like this (but this won’t help you if you are selecting multiple columns).
If you are confused as to why selecting multiple columns wouldn’t work:
Just think about it a moment as follows:
You want:
How should it pick that ‘id’ for Test in the Distinct mixed table?
As such, it gives you all DISTINCT combinations of all the data you’ve asked for.
i.e.