I'm trying to update the attendance of a student given the University Seat Number(USN) and the Subject. I used the following query and it says none of the rows were affected.
Update `Student Attendance` as sa
JOIN Subjects as s ON sa.`Subject Code`=s.`Subject Code`
set sa.Attendance ='5' AND sa.`Absent Days`='2017-10-12'
where sa.USN ='1ks15bt001' AND s.Subject='English';
When I ran the the below query alone I got this as the output :
Select sa.USN,s.Subject,sa.Attendance
From `Student Attendance` as sa
JOIN Subjects as s ON sa.`Subject Code`=s.`Subject Code`
where sa.USN ='1ks15bt001' AND s.Subject='English';
Schema of Student Table :
CREATE TABLE `Student` (
`USN` varchar(10) NOT NULL,
`DOB` date NOT NULL,
`Dep` varchar(3) NOT NULL,
`SEM` int(1) NOT NULL,
`Class` varchar(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `Student`
ADD PRIMARY KEY (`USN`),
ADD KEY `Dep` (`Dep`);
Student Attendance :
CREATE TABLE `Student Attendance` (
`USN` varchar(10) NOT NULL,
`Subject Code` varchar(6) NOT NULL,
`Attendance` int(11) NOT NULL DEFAULT '0',
`Absent Days` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `Student Attendance`
ADD PRIMARY KEY (`USN`,`Subject Code`),
ADD KEY `ABC` (`Subject Code`);
Subjects :
CREATE TABLE `Subjects` (
`Subject` varchar(40) NOT NULL,
`Subject Code` varchar(6) NOT NULL,
`Dep` varchar(3) NOT NULL,
`Sem` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `Subjects`
ADD PRIMARY KEY (`Subject Code`,`Subject`) USING BTREE,
ADD KEY `bgf` (`Dep`);
