Im revising my auto-complete style search script. The site has 2 categories... movies and tv shows. Currently, the auto-complete query string looks like this:
SELECT * FROM movies WHERE mov_title LIKE '%" . $queryString . "%' AND mov_status = 1 AND mov_incomplete = 0 ORDER BY mov_type, mov_title LIMIT 10
The problem with this is if there are more than 10 matches with mov_type = 1 (since it orders it by type first), there wont be any mov_type = 2 records, that would make it into the results.
Is there a way for it to do 5 records from mov_type 1, and then 5 records from mov_type 2. The only way I figured you can do it is, run 2 queries and use UNION to put them together.
I always want to have 10 results if possible... and if a search yields 1 movie (mov_type = 1) and 14 tv shows (mov_type = 2), using UNION this will yield 6 records (since I would do LIMIT 5 on each query), instead of 10 (1 movie, and 9 tv shows).
Any other way I can do this?