|
|
 |
FN-FORUM: SQL SELECT DISTINCT with INNER JOIN
date posted 4th September 2007 15:30
Hi
I'm adding a search function to a site that searches through the
titles of courses in my table tblCourses. However also have a table
called tblCourseListings so that courses can belong to more than one
category. So my structure is this:
tblCourses
- ID
- Title
tblCourseListings
- ID
- CourseID
My search works OK using =85
strSQL1 =3D "SELECT tblCourses.Title AS Title, tblCourses.ID,
tblCourses.Description AS Description, tblCourses.Active,
tblCourseListings.CourseID, tblCourseListings.ID AS CourseListingID
FROM tblCourses INNER JOIN tblCourseListings ON tblCourses.ID =3D
tblCourseListings.CourseID WHERE =85 etc.
Except that if a match is found it will list the course in every
category it belongs to. I've read about SELECT DISTINCT on this page
=85
http://www.w3schools.com/sql/sql_select.asp
=85 but I think because I have a join it's not so simple. Basically I
want tblCourses.ID to be unique. I've tried =85
strSQL1 =3D "SELECT DISTINCT tblCourses.ID, tblCourses.Title AS Title,
tblCourses.Description AS Description =85 etc.
=85 but it makes no difference. Any help is appreciated.
TIA
Paul
|
 |
|