开发者

Multiple values in SELECT

开发者 https://www.devze.com 2023-03-31 00:40 出处:网络
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 h

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

精彩评论

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