Use of DISTINCT

D

D.Logue

This query produces lots of reapeats. It gives the same output
without DISTINCT as with DISTINCT.

SELECT DISTINCT [Last Name], [First Name], b.City
FROM Staff, Branch AS b;
 
R

Rick Brandt

D.Logue said:
This query produces lots of reapeats. It gives the same output
without DISTINCT as with DISTINCT.

SELECT DISTINCT [Last Name], [First Name], b.City
FROM Staff, Branch AS b;

You have no join between the two tables so you are getting a Cartesian
product. Every row in Staff will be repeated for every row in Branch. If
the two tables have a field (or fields) in common then you should create a
join on those fields.
 
Top