如何编写一个带字符串作为输入的where子句的select查询? [英] how to write select query with a where clause that takes a string as input?
本文介绍了如何编写一个带字符串作为输入的where子句的select查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是我的功能.我只想运行一个查询-
Following is my function.All I want is to run a query-
select * from testtitles where testCategory="PICK";
所以这个PICK是我的字符串输入,没有被接受,并且没有这样的列出现错误.有人可以帮助我吗?我已经尝试了所有方法.我的代码-
So this PICK is my string input which is not being accepted and error is coming no such column.can anyone help me ? I have tried all ways.my code-
推荐答案
尝试一下:String sql = "select * from testtitles where testCategory='" + userinput + "'";
这篇关于如何编写一个带字符串作为输入的where子句的select查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文