Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CSqlite search.
#2
Macro
Code:
Copy      Help
out
#compile CSqlite

str dbfile="$desktop$\test.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("SELECT * FROM table1 WHERE A LIKE 't%e'" 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]


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)