Home > other >  For help on python SQL like fuzzy query
For help on python SQL like fuzzy query

Time:10-01

Need to query to begin with g characters
In SQL should be g %
The % in python is a formatting characters
Inquire on the net for a variety of methods, no matter use, shows that it is wrong

CodePudding user response:

R 'select * from... 'try adding a r

CodePudding user response:

Sql_cmd="' select * from TBL where FLD like 'g %'" '

Cursor. The execute (sql_cmd)

CodePudding user response:

Not have any backquotes ` `

CodePudding user response:

In python and want to use when you want to use % format string can use the format, devoid of you turn to escape character, usage is simple, it is assumed that query the beginning of the student's field of g
A=input (" please enter your initials of fuzzy query: ")
SQL="select * from tablename where student like '{}' % '". The format (a)

CodePudding user response:

"XXXX like 'g %'" or "XXXX like" g % '"

CodePudding user response:

refer to fifth floor ice of wind response:
"XXXX like 'g %'" or "XXXX like" g % "' can

Positive solution
  • Related