01-07-2009, 06:29 PM
Thanks for the example...
Changed it a bit to make it a little more versitle...Do you see anything wrong with this idea or have any other thoughts?
Function Function8
Changed it a bit to make it a little more versitle...Do you see anything wrong with this idea or have any other thoughts?
Function Function8
out
#compile CSqlite
str SearchWord="tre"
;;formats SearchWord "t%r%e%
ARRAY(str) a.create(SearchWord.len)
for(_i 0 a.len)
,a[_i].get(SearchWord _i 1); _s.format("%s%s%%" _s a[_i])
SearchWord=_s
str sqlSearchWord.format("SELECT * FROM 'table1' WHERE A LIKE '%s'" SearchWord)
str dbfile="$desktop$\searchDB.db3"
str sql
;create database for testing
CSqlite db1.Open(dbfile)
db1.Exec("DROP TABLE table1")
db1.Exec("CREATE TABLE 'table1' (A,B)")
db1.Exec("INSERT INTO table1 VALUES ('one','two')")
db1.Exec("INSERT INTO table1 VALUES ('three','four')")
db1.Exec("INSERT INTO table1 VALUES ('te','five')")
;search
CSqlite db2.Open(dbfile)
ARRAY(str) ar; int r c
db2.Exec(sqlSearchWord ar) ;;in SQL, % is used instead of * (0 or more characters), _ instead of ? (single character)
for r 0 ar.len(2)
,out "row %i" r+1
,for c 0 ar.len(1)
,,out ar[c r]