Forums

ASP

This topic is locked

Small SQL query question

Posted 28 Oct 2005 18:50:19
1
has voted
28 Oct 2005 18:50:19 Javier Castro posted:
I have the following query that I use for displaying a list of companies by industry Segment i.e. Engineering, construction, etc. the ID for the segment that I require is 11. Everything works fine until here. However, if I add to the database another user that happens to work for the same company my list will show the same company twice. how can I display the list of companies without duplicating.

Any ideas?

SELECT intCompanyID, intSegment, txtCompanyName
FROM tblUsers, tblCompanies
WHERE intCompanyID = intCompID AND intSegment LIKE 11
ORDER BY txtCompanyName ASC

Replies

Replied 30 Oct 2005 20:06:36
30 Oct 2005 20:06:36 Michael Behan replied:
SELECT DISTINCT, rather than just SELECT should do it.
Replied 31 Oct 2005 05:03:59
31 Oct 2005 05:03:59 Javier Castro replied:
Thanks Michael, it worked.


Cheers,
Javier

Reply to this topic