2014-09-04 70 views

回答

0

你在這裏:

Select * from Table Where Name in ("Tom", "Dick", "Harry"); 
1

你需要工藝的SQL語句,並使用WHERE ...在...

SELECT column_name(s) 
FROM table_name 
WHERE column_name IN (value1,value2,...); 
+0

我認爲OP想要一個通用數組的解決方案。 – giusva 2017-03-07 18:04:18

2

您可以使用查詢IN關鍵字把它傳遞多個項目在括號內由comma分隔,如:

String query = "Select * from Table Where Name IN ("; 

for(int i =0 ;i<arrayName.length();i++){ 
    query = query + "'" +arrayName(i) + "'" + ","; 
} 

query = query.substring(0, query.length()-1); 
query = query + ")"; 

// execute your query here 

這會通過你的查詢如:

Select * from Table Where Name IN ('arrayvalue1','arrayvalue2','arrayvalue3'); 

根據數組的長度。

相關問題