1.11M Members

query for multiple values in one column

 
0
 

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..

 
0
 

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

 
0
 

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.

 
0
 

Try something like this:

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

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

Question Answered as of 6 Months Ago by pritaeas
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article