I'm trying to build a query that seaches keywords in a table and displays matching results in order of best match.
To do this, I thought I'd write a bit of code that takes the search words, writes SELECT statements looking for each word in turn, UNION ALL the results together and do some group totalling to find out wich record got the most hits.
Here's what I've done so far:
My code generates the following SQL query when you supply it with (for example) "email delete save":
Could someone point out how I'd finish this query to produce a set of results that list the CaseID and the ammount of times it was found in the search?
Any and all help greatly appriciated as allways.
To do this, I thought I'd write a bit of code that takes the search words, writes SELECT statements looking for each word in turn, UNION ALL the results together and do some group totalling to find out wich record got the most hits.
Here's what I've done so far:
My code generates the following SQL query when you supply it with (for example) "email delete save":
SELECT Cases.CaseID
FROM Cases
WHERE (((Cases.keywords) Like "*email*"))
UNION ALL
SELECT Cases.CaseID
FROM Cases
WHERE (((Cases.keywords) Like "*delete*"))
UNION ALL SELECT Cases.CaseID
FROM Cases
WHERE (((Cases.keywords) Like "*save*"));
FROM Cases
WHERE (((Cases.keywords) Like "*email*"))
UNION ALL
SELECT Cases.CaseID
FROM Cases
WHERE (((Cases.keywords) Like "*delete*"))
UNION ALL SELECT Cases.CaseID
FROM Cases
WHERE (((Cases.keywords) Like "*save*"));
Could someone point out how I'd finish this query to produce a set of results that list the CaseID and the ammount of times it was found in the search?
Any and all help greatly appriciated as allways.