2

does something like followin exist?

('''select * from TABLE where ? in FIELD''',(VAR))

I need to select all table rows where FIELD just contains the text of VAR (so not needed FIELD=VAR) I'm using python3 and sqlite3.

forpas
  • 160,666
  • 10
  • 38
  • 76
Tommy
  • 101
  • 8

1 Answers1

1

You can use the function INSTR():

sql = "SELECT * FROM tablename WHERE INSTR(FIELD, ?)"

or the operator LIKE:

sql = "SELECT * FROM tablename WHERE FIELD LIKE '%' || ? || '%'"

to get the rows that contain the value of VAR:

execute(sql, (VAR,))
forpas
  • 160,666
  • 10
  • 38
  • 76