开发者

Multiple values in SELECT

How could i formulate a开发者_如何学Python SELECT query where the values of one of the fields is dynamic, specfically, the values of sintom, which is an array of String,are determined upon execution how could I modify this query:

       q = "SELECT DISTINCT nome FROM malattia WHERE eta='" + age + "' AND sesso='" + sexstr + "' AND etnia='" + etniastr + "' AND sintomi IN('" + sexstr + "')";

I would need something like this:

  ... AND sintomi IN('" + sexstr[0] + "','" + sexstr[1] + "','" + sexstr[2] + "')";

The array sintom can have a length of 1 upto 10, I didn't opt for preparedstatement thought it would be abit simple, if i use concatenation of strings.More over i can't use a loop because i need to accomplish it in a single query. Thanks in advance!


Use guava Joiner.on("','").join(array) or commons-lang StringUtils.join(array, "','")

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜