January 23rd, 2013, 11:29 AM
SQL Query giving duplicate records
I'm trying to pull from our database all the students that are absent on a certain day. I have it where I get all the students but it's duplicating records and I don't know why.
select emf.L_NAME,emf.F_NAME, atn.ID_NUMBER, atn.SAF_CODE, atn.SAF_DATE1
INNER Join ATN
Where atn.SAF_CODE='ne' and atn.SAF_DATE1='1-22-2013'
January 23rd, 2013, 12:25 PM
most likely because there are multiple ATNs for each EMF (whatever they are)
January 23rd, 2013, 12:29 PM
If that's the case then what can I do about it?
Originally Posted by r937
January 23rd, 2013, 12:44 PM
So how would I do this then.
I have three tables that I need information from.
ATN where I need attendance code, attendance date, id_number of all the students that are absent on todays date
Contact Table where I need the phone number for the ID number from the ATN table
and the EMF table where I need the first name and last name of the ID number that I am getting from the ID_Number from the ATN table
January 23rd, 2013, 05:02 PM
suddenly, there are three tables instead of two
the duplicates per student are doubtless coming from duplicate contacts