I have a table in mysql cauled subjects consiting of "id","subject1","subject2","subject3","subject4","subject5". What i want is to write some php code to search these. eg search for all students doing Maths, English and Physics only. How do i do this?
MySQL has search function. 1. Alter table to fullindex on columns. 2. use Match Against to do search. Search web for more detail.
I would say your database design is not optimal. I would create 3 tables. One with students, one with what subjects each student is doing (studentID, SubjectID) and one table with SubjectID and Subject. Then you can use a very easy SQL syntax, select * from Studens S inner join StudentSubjects SS on S.StudentID = SS.StudentID inner join Subjects SU on SU.SubjectID=SS.Subjectid where Subject in("Math","English","Physics");