The only way I can think to do this with any kind of efficiency would be to split up the words, both the ones on the table and the string being searched for, into individual letters stored separately. With the least possible DB changes store the word as a comma separated list of letters, but it would be better to store each letter in another table, one row per letter per row on the first table
For example of the first idea.
MyTable
id word letters letter_count
1 Table t,a,b,l,e 5
2 School s,c,h,o,l 5
3 Automotive a,u,t,o,m,i,v,e 8
the folowing sql
SELECT MyTable.id, MyTable.word
FROM MyTable
WHERE (IF(FIND_IN_SET('l', MyTable.letters), 1, 0)
+ IF(FIND_IN_SET('o', MyTable.letters), 1, 0)
+ IF(FIND_IN_SET('h', MyTable.letters), 1, 0)
+ IF(FIND_IN_SET('c', MyTable.letters), 1, 0)
+ IF(FIND_IN_SET('s', MyTable.letters), 1, 0)
+ IF(FIND_IN_SET('a', MyTable.letters), 1, 0)
+ IF(FIND_IN_SET('u', MyTable.letters), 1, 0)
+ IF(FIND_IN_SET('t', MyTable.letters), 1, 0)
+ IF(FIND_IN_SET('m', MyTable.letters), 1, 0)
+ IF(FIND_IN_SET('v', MyTable.letters), 1, 0)
+ IF(FIND_IN_SET('e', MyTable.letters), 1, 0)) >= MyTable.letter_count
This is not using indexes, but I think will be marginally quicker than using LIKE. But still very slow and not that nice
Bit more flexible, and coping with words of up to 100 letter you could do something like this. Still nasty to read and won't be fast, but easy to just plonk in the jumble of letters you are searching for (untested so please excuse any typos):-
SELECT MyTable.id, MyTable.word, MyTable.letter_count, COUNT(*) as letter_match
FROM MyTable
INNER JOIN
(
SELECT SUBSTR('hqaletabzu', tens.aCnt * 10 + units.aCnt + 1, 1) AS aLetter
FROM
(SELECT 1 aCnt UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 UNION SELECT 0) units
CROSS JOIN
(SELECT 1 aCnt UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 UNION SELECT 0) tens
WHERE LENGTH('hqaletabzu') > (tens.aCnt * 10 + units.aCnt)
) sub1
ON FIND_IN_SET(aLetter, MyTable.letters)
GROUP BY MyTable.id, MyTable.word, MyTable.letter_count
HAVING letter_match >= letter_count
EDIT
Further suggestion using a table of letters. This should be quicker as if indexes are set up they can be taken advantage of.
Demo tables:-
CREATE TABLE MyTable
(
id INT,
word VARCHAR(255)
);
INSERT INTO MyTable (id, word) VALUES
(1, 'Table'),
(2, 'School'),
(3, 'Automotive');
CREATE TABLE MyTableLetters
(
id INT,
mytable_id INT,
letter CHAR(1)
);
INSERT INTO MyTableLetters VALUES
(NULL, 1, 't'),
(NULL, 1, 'a'),
(NULL, 1, 'b'),
(NULL, 1, 'l'),
(NULL, 1, 'e'),
(NULL, 2, 's'),
(NULL, 2, 'c'),
(NULL, 2, 'h'),
(NULL, 2, 'o'),
(NULL, 2, 'l'),
(NULL, 3, 'a'),
(NULL, 3, 'u'),
(NULL, 3, 't'),
(NULL, 3, 'o'),
(NULL, 3, 'm'),
(NULL, 3, 'i'),
(NULL, 3, 'v'),
(NULL, 3, 'e');
With these tables the following SQL will get you what you want:-
SELECT MyTable.id, MyTable.word, COUNT(MyTableLetters.id) AS MyTableLetters_count, COUNT(aLetter) as letter_match
FROM MyTable
INNER JOIN MyTableLetters ON MyTable.id = MyTableLetters.mytable_id
LEFT OUTER JOIN
(
SELECT DISTINCT SUBSTR('hqaletabzu', tens.aCnt * 10 + units.aCnt + 1, 1) AS aLetter
FROM
(SELECT 1 aCnt UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 UNION SELECT 0) units
CROSS JOIN
(SELECT 1 aCnt UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 UNION SELECT 0) tens
WHERE LENGTH('hqaletabzu') > (tens.aCnt * 10 + units.aCnt)
) sub1
ON sub1.aLetter = MyTableLetters.letter
GROUP BY MyTable.id, MyTable.word
HAVING letter_match >= MyTableLetters_count
Note that the main sub query splits up the search letters into a row per letter, and eliminates duplicate letters.