像sql中的命令
我尝试编写一个带有类似命令的查询以搜索特殊名称,但是我需要从用户那里获取值,我需要读取该值,但是我的SQL代码在“ kike”部分中存在问题,我该如何修复?
sql = '''SELECT Name FROM newtest WHERE Name LIKE = %s'''
val = (n)
myobj = mycurs.execute(sql , val)
有什么问题?
您在SQL语法中有错误;查看与您的MariadB服务器版本相对应的手册,以获取正确的语法,以接近1
在第1行中使用'=%s'
这是错误
I tried to write a query with Like command to search for special Name , but i need to get the value from User and i need to read the value but my sql code has problem with "LIKE" section , how can i fix it ?
sql = '''SELECT Name FROM newtest WHERE Name LIKE = %s'''
val = (n)
myobj = mycurs.execute(sql , val)
what's the problem ?
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '= %s' at line 1
this is the error
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
删除“ =”符号。类似命令不使用它 - 请参见 https:///www.w3schools.com/sql/ssql/ sql_ref_like.asp 示例。
Remove the "=" sign. The LIKE command doesn't use that - see https://www.w3schools.com/sql/sql_ref_like.asp for an example.
如果您需要搜索非外观匹配(即名称在列中的任何位置),则可以将查询更改为:
If you need to search for non-exact matches (i.e. the name is anywhere inside the column) you can change the query as: