I have a table called Classes which stores information on College classes. It has the columns Department, Course, and Section. I currently have an autocomplete where users can enter classes. For example if they type “ECON” it shows ECON-E 201 12345, etc. The autocomplete query is LIMIT’ed to 10.
Now, the problem with my autocomplete is that it doesn’t give diversity in its responses. If they type “E” it will show 10 ECON classes, but not ENG (English) classes. Is there a way to sort the response to give as many departments, courses, and sections (in that order) as possible?
It depends also on the setup of your database. If you have a separate field for the names (such as “ECON”), then you could do:
Looking at your comment, how does this work for you? (I’m only checking against Department_Code, but in place of that, you could have your REPLACE line…)
This will return only a single record for each of the Departments that begin with ‘E’, but if the user enters ‘ENG’, then all of the courses for ‘ENG’ will be pulled.