I need a Mysql query for my following problem.
I have two tables.
Exam with fields id and examname
Exam_Applied with fields id , examname and student_id
Here student_id is the id of student who applied the exam and I am storing in Exam_Applied
Now I need a query to Select the examname From Table Exam which are not applied by the particular student_id
help me plz.
You can use NOT IN to answer your question. Basically what it does is inside subquery, it gets all the examname taken by the specific student. The NOT IN checks the examName of table Exam which are not present on table Exam_Applied
SELECT id, examName
FROM Exam
WHERE examName NOT IN
(
SELECT examName
FROM Exam_Applied
WHERE Student_ID = 'idHERE'
)
Hope this makes sense
Related
I have 2 tables
From table 1(student): I want id, name, and roll_no
From table 2(score): I want SUM(total), SUM(score) with some condition
And I want all student same class data from student table combine with score table to get each student SUM(total) and SUM(score) of some condition in student table.
In score table I have student_id name column and in student
I have id column which can be linked to each other if possible...
How can I achieve this??
I want this all-in-1 query to get the data in ascending order by score column...
i know this question has been asked on this platform but I couldn't get enough details to help me with my problem.
I have three tables I am selecting from: student, subjects and exam table.
student table:
Results Table
And the Subjects table:
If you take a look at the first table(results table) you will see the subjects codes. What I am trying to achieve is like the diagram below:
Here is my result table after I selected those results from database for TS2018007.
My query for image four:
SELECT distinct s.regiNo, s.firstName as fname, s.middleName as mname, s.lastName as lname,
s.gender, s.class_group, c.subjects,e.First_CA, e.Second_CA, e.examid, e.scored,
e.internaltype, e.Class, e.Year
FROM student s inner join exam e on s.regiNo = e.Roll_Number
inner join subjects c on e.sub_id = c.subect_code
group by s.regiNo, s.firstName, s.middleName, s.lastName, s.gender, s.class_group,
c.subjects, e.First_CA, e.Second_CA, e.examid, e.scored, e.internaltype,
e.Class, e.Year
How can I create an html table with dynamic rows and columns where row data relies on column heading everytime a new subject score is added to the exam table? I don't want hard code.
Thanks in advance for your help.
I want to count the student name field.
i have three table
table 1
invoice
invoice_id student course_id timing_id day_id
table 2
course
course_id course_name
table 3
timing
timing_id time
table 4
days
days_id name
I want to count the number of students that are in one course, in same timing, in same day from invoice table
what is the query?
view , model, controller?
Try to learn Group by and Having in mysql then you can solve this problem
I am working on a school database system based on php mysql. the basic structure is as below:
Table Class-Details of all classes.
Table Student-Details of all students
Table Semester-Details of all Semesters
Table class–Semester. This table solves many to many relation, primary key- IDs of both class and semester.
Table Subject -Details of all Subjects
Table class–Subject. This table solves many to many relation, primary key- IDs of both class and semester.
Table marks- consists of student ID, Subject ID, Semester ID, Marks Achieved.Foreign Key ClassID, SemesterID, SubjectID
I am trying to get a table in below mentioned format:
ENGINE = InnoDB
AUTO_INCREMENT = 53
DEFAULT CHARACTER SET = utf8;
So far I could achieve individual marks of subjects in every record
my query:
SELECT
m.MarkID, m.studentID,
sm.ExamName, sb.Subject,
sm.MaxMarks, m.MarksRecvd
FROM marks AS m
RIGHT JOIN student AS st
ON m.studentID=st.studentID
RIGHT JOIN semester AS sm
ON m.ExamID=sm.ExamID
RIGHT JOIN subject AS sb
ON m.SubjectID=sb.SubjectID
WHERE m.studentID = $studentID
Please help me on this... I am getting a record for every mark recvd like below.
However I want to group all semester marks in one row like below:
Friends pls let me know if my query is clear
I am now having a problem sorting the data in my PHP page where the data displayed is combined of two tables as the both tables are linked by a foreign key in one of the table.
two tables are as below
Table name: Students
stu_id
stu_name
.
.
.
stu_course_id
Table name: courses
course_id
course_name
Wen displaying the data it is displayed in following format:
Student id | Student name | student course
----1 --------------john-------------engineering
----2--------------dave---------------business
I am able to sort the data by name which is pretty easy but I am having difficulty sorting the data by course name. Is this possible as the course name is not in the same table as student?
select s.stu_id, s.stu_name, c.course_name
from students s
inner join courses c on s.stu_course_id = c.course_id
order by c.course_name asc
Of course. Simply refer to the column name without ambiguity, i.e.:
ORDER BY courses.course_name
Show me your query and I'll make that work.
Yes, use the ORDER BY clause.
SELECT * FROM courses ORDER BY course_name