hi.please help me with mysql query.
i have a table tblGrades with fields ID, Subject, Remarks.

how can i create a stored procedure that will display the students that have subjects(user input) and Remarks='Passed'?

the Subjects will depend on the user, therefore it may be one or two or three subjects, etc they want and all are 'Passed'.

i was able to make the query like this:

select * from tblGrades where Remarks='Passed' and Subjects in('English',Science') group by ID having count(*) ='2'

the results are those students who Passed BOTH ENGLISH and SCIENCE.
but what if the user chose ENGLISH, SCIENCE, MATH and others?

please help.

thanks..

You mean you want to check if a student passed all of his subjects?

yes.and display those students. .
Just want to clear,the subjects that will be included in the query will depend on the user input. .thanks.

Try something like this:

SELECT Id, GROUP_CONCAT(Subject) FROM tblGrades GROUP BY Id, Remarks HAVING GROUP_CONCAT(DISTINCT Remarks) = 'Passed'

thanks for the reply.
I solvd it after long time of searchng. .i added function that splits the string list. .thanks anyway. .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.