database - Displaying rows from different tables to one ListView in Android - without SQL JOIN -
i'm super-novice @ android programming , have project i'm stuck on.
i have database of (conlang) dictionaries each language in own table. user searches these , results display in listview. right now, i've got working search 1 table.
i want able search 3 tables , display results in one listview rows each of tables. i'd indicate table each row came from. results display like:
from language
lang term : english term
additional information
i've set cursoradapter , have working one of 3 tables.
...
since dictionaries came different sources, have different information. example:
one has columns engterm, vlangterm, fulldefinition
another has engterm, rlangterm, partofspeech
and other has engterm, glangterm, partofspeech, , pronounciationguide (possibly).
for example, table1 might contain results "land," "landing gear" , "landscape" , table2 might contain "land," "landing" , "island" , table3 might contain "bland" , "homeland."
the user can search these tables right only english term, , can select match full word or partial word.
because of how structured, i'm guessing there no way join query.
i don't know if helps @ all, right now, i've got method in sqliteopenhelper class:
public cursor searchdictionarybyenglish (boolean matchfullwordonly, string searchterm) { string sql = "select * " + table_vulcan + " " + column_all_eng_term + " match ?"; if (!matchfullwordonly) searchterm = "*" + searchterm + "*"; return mdatabase.rawquery(sql, new string[]{searchterm}); } (it fts3 table it's searching, match rather like.)
i hope i've made clear i'm trying accomplish, i'm not sure start. i've found answers mergecursor don't know how apply because of different number , names of columns.
here's how union if don't have 1 of columns in 1 of tables, work if you're searching through common column, tables have.
select field1 , field2 , field3 ( select field1 , field2 , field3 table1 union select field1 , field2 , field3 table2 union select field1 , field2 , null field3 table3 ) tbl tbl.field1 '%search_string%' note null field3 in last union.
Comments
Post a Comment