Use of DISTINCT

  • Thread starter Thread starter D.Logue
  • Start date Start date
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;
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top