0

I'm trying to make an android game having all single English word. and I successfully made with minimal time.

So my problem is how to match my input random letters to match a word.

for example my characters are 'A','B','C','O','U','P';

so I want the result of this words Ab, Cop, Cap, Bap, Bop, Cup

I already try this example

SELECT *FROM 
TABLE_NAME 
WHERE COLUMN_NAME LIKE '%A%' 
AND COLUMN_NAME LIKE '%B%' 
AND COLUMN_NAME LIKE '%C%' ...etc AND 
WORD_LEN <=6

I ADD A COLUMN WORD_LEN TO MINIMIZE THE RESULT

BUT IT SHOW ME A WRONG RESULT

PM 77-1
  • 12,254
  • 20
  • 64
  • 106
  • 1
    What's in your table? What the right result should be? In your example you have 2-letter and 3-letter words, however in your SQL you require all of your letters to be present in a matching field. So what's the exact requirement. – PM 77-1 Sep 17 '14 at 01:15
  • @PM77-1 probably he wants to get any valid words (stored in DB) that can be constructed by those characters. – Andrew T. Sep 17 '14 at 01:21
  • If that's the case, [this](http://stackoverflow.com/questions/1647801/algorithm-question-on-finding-all-valid-words-in-dictionary) is related with your issue. – Andrew T. Sep 17 '14 at 01:25
  • AndrewT is right. I lessen the result using column_len since i have 6 letters the word_len is <=6, the result i want is indicate above – Su Pla Dho Sep 17 '14 at 01:58
  • I want a result that no other letters involved – Su Pla Dho Sep 17 '14 at 02:03
  • Since you want to match the first letter only, remove the first **%**. Just use `A%`, `B%`, `C%`, ... this means "Search the words **starting with** A, B, C, ..." – Phantômaxx Sep 17 '14 at 07:30
  • @FrankN.Stein That query wants to check if *all* characters occur in the word. – CL. Sep 17 '14 at 11:10
  • This is not possible with SQLite. You have to search a [trie](http://stackoverflow.com/questions/1647801/algorithm-question-on-finding-all-valid-words-in-dictionary), which probably needs to be stored in a custom file. – CL. Sep 17 '14 at 11:11
  • @CL The OP said: I want the result of this words `Ab`, `Cop`, `Cap`, `Bap`, `Bop`, `Cup` - So, I guess my Like is better than the original, for the requested result. – Phantômaxx Sep 17 '14 at 11:48

0 Answers0