java - I need an SQL query to find all the words you can make with a set of letters, including up to two blank tiles -


i have database table called dictionary following fields dictionary entries:

public static final string column_name_uid = "_id_"; public static final string column_name_word = "word"; public static final string column_name_word = "wordsorted"; public static final string column_name_word_length = "length"; public static final string column_name_count_a = "count_a"; public static final string column_name_count_b = "count_b"; public static final string column_name_count_c = "count_c"; public static final string column_name_count_d = "count_d"; public static final string column_name_count_e = "count_e"; public static final string column_name_count_f = "count_f"; public static final string column_name_count_g = "count_g"; public static final string column_name_count_h = "count_h"; public static final string column_name_count_i = "count_i"; public static final string column_name_count_j = "count_j"; public static final string column_name_count_k = "count_k"; public static final string column_name_count_l = "count_l"; public static final string column_name_count_m = "count_m"; public static final string column_name_count_n = "count_n"; public static final string column_name_count_o = "count_o"; public static final string column_name_count_p = "count_p"; public static final string column_name_count_q = "count_q"; public static final string column_name_count_r = "count_r"; public static final string column_name_count_s = "count_s"; public static final string column_name_count_t = "count_t"; public static final string column_name_count_u = "count_u"; public static final string column_name_count_v = "count_v"; public static final string column_name_count_w = "count_w"; public static final string column_name_count_x = "count_x"; public static final string column_name_count_y = "count_y"; public static final string column_name_count_z = "count_z"; 

i want able search instance test* , find words can made out of "t" "e" "s" "t" , wildcard, such words "tests" (s wildcard), "setts" (s wildcard), "set", "tet" "es" "te", "best" (b wildcard), etc... can make combination of letters.

i have tried methods this, example finds 4 letter words without wildcard:

select * dictionary   count_e=1 , count_s=1 , count_t=2   select * dictionary  length <=4 

this produces:

"137075"    "sett"  "estt" "145808"    "stet"  "estt" "153675"    "test"  "estt" "153851"    "tets"  "estt" 

now, know, kind of dicreet math problem @ heart.

here how can 5 letter words 1 blank space , letters provided in last query:

select * dictionary   count_e=1 , count_s=1 , count_t=2   intersect  select * dictionary  length <=5 

results:

"97705"     "netts" "enstt" "137075"    "sett"  "estt" "145250"    "state" "aestt" "145808"    "stet"  "estt" "152303"    "taste" "aestt" "152333"    "tates" "aestt" "152632"    "teats" "aestt" "153361"    "tents" "enstt" "153675"    "test"  "estt" "153676"    "testa" "aestt" "153733"    "testy" "estty" "153769"    "teths" "ehstt" "153851"    "tets"  "estt" "153874"    "texts" "esttx" "156575"    "totes" "eostt" "157952"    "trets" "erstt" "172060"    "yetts" "estty" 

however, i'd have go through iterations of combinations of letters hiding sub-words in there... can me think of more elegant approach finding anagrams , sub-words query , 2 wildcards? aware can use regexp in sql, might way. don't know @ point, , i'm taking problem hive...

is there query, or series of queries, or intersections, joins, etc... me solve problem?

update think may have stumbled upon this, not sure if working correctly. appreciated:

select * dictionary  ( count_e<=1 , count_s<=1 , count_t<=1  ) intersect select * dictionary length =(count_e+count_s+count_t+1)     order length 

the +1 account 1 blank space. two, i'm thinking of doing +2, etc... +0 letters, , can make them.

you must perform following, put concatenation of fields of table follows:

concatenacion = "(_id||' '||desc_art||' '||nom_proveedor||' '||marca) '"+resultado+"'" +             "or (_id||' '||nom_proveedor||' '||marca||' '||desc_art) '"+resultado+"'" +             "or (marca||' '||nom_proveedor||' '||desc_art||' '||_id) '"+resultado+"'" +             "or (marca||' '||nom_proveedor||' '||_id||' '||desc_art) '"+resultado+"'" +             "or (desc_art||' '||nom_proveedor||' '||marca||' '||_id) '"+resultado+"'" +             "or (desc_art||' '||_id||' '||nom_proveedor||' '||marca) '"+resultado+"'"; 

then make request , in clause must put conecatenacion example:

cursor=bd.rawquery("select _id, desc_art, cant_art, desc_bulto, precio"+getdefaultnrolista(codcliente)+", tiene_imagen,marca listas_precios "+concatenacion+" order desc_art asc", null); 

i work me, hope serves


Comments