Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inner join recordset

Status
Not open for further replies.

beckyr51

Programmer
Jan 29, 2008
36
IE
Can someone help me with my syntax here. I am trying to send an email to people if they have at least one student in the faculty specified by an inputbox. This works but it sends as many emails as there are students in that faculty i.e: if someone has 2 students in a faculty they get 2 emails when i only want them to get 1. Here's my code:

Set rs = db.OpenRecordset("Select [tblTutor].[TU_EMAIL]from [tblTutor]inner join [tblStudents] on [tblTutor].TU_CODE = [tblStudents].STU_TU_CODE where [tblStudents].[STU_FAC_NO] = " & "'" & fac & "';")
 
Try this:
Code:
Set rs = db.OpenRecordset("Select [red]DISTINCT[/red] [tblTutor].[TU_EMAIL]from [tblTutor]inner join [tblStudents] on [tblTutor].TU_CODE = [tblStudents].STU_TU_CODE where [tblStudents].[STU_FAC_NO] =  " & "'" & fac & "';")
Using DISTINCT will only allow unique rows of data to be returned (like a GROUP BY).

Hope this helps


HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top