You are here: Re: search string « PHP SQL « IT news, forums, messages
Re: search string

Posted by Bob Stearns on 10/13/27 11:17

Mark & Ingrid Nugent wrote:
> One table of my database could contain multiple values eg student_courses,
> each student could have done many different courses.
>
> For a search engine, I want to be able to tick a checkbox and get all the
> students who have done that course. However, if I tick two or more
> checkboxes I want to get only the students that have done all the selected
> courses, not the students that have done just any of the selected courses.
>
> I think that means I will have to run a query "SELECT student_id FROM
> student_courses WHERE course_id = $id OR course_id = $id etc etc , and
> filter the results with PHP.
> Has anyone got a neat solution? Is there any way that MySQL could refine the
> query results?
>
> Mark
>
>
SELECT student_id FROM student_courses WHERE course_id = $id1
INTERSECT
SELECT student_id FROM student_courses WHERE course_id = $id2

should do what you want.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация