Hi.

I'm working on a query I would like to sort a certain way. If the search term matches the start of any word in the title of a book, I want this result first. If there are multiple matches, I want them sorted by date submitted. Afterwards I want matches from the book description, and if there are multiple matches I want them sorted by date submitted.

I have already made a query that works. My concern is that the query is relatively slow. I would be very happy if anybody could point out a better way for to phrase such a query. This is what I have so far:

SELECT DISTINCT id, title, description
FROM books
WHERE (title RLIKE search_phrase% OR description RLIKE search_phfrase% )
ORDER BY IF(title RLIKE search_phrase%, 0, 1), time_submitted DESC";

_________________________________________________________________
Send a QuickGreet with MSN Messenger http://www.msnmessenger-download.com/tracking/cdp_games



-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to