推 PsMonkey:用 Java 的話,還是寫 StringBuffer 等級的範例吧... XDE 06/25 11:20
※ 引述《zxvc (zxvc)》之銘言:
: ※ 引述《PsMonkey (痞子軍團團長)》之銘言:
: : select * from fooTable where x='abc' or y='abc' or z='abc'
: : 我實在不懂這個問題困擾點在哪裡... [逃]
: 問題是如果欄位很多的話這種方法就不實用了。
: 請問有沒有更簡單的方法?
不管是甚麼語言都有可以把欄位抓出來的方法吧:)
String str="'abc'";
String sql="select * from fooTable where "
String 欄位名稱[] = xxxxx;
for(int i=0;i<欄位名稱.length;i++){
sql+= 欄位名稱[i]+"="+str
if(i!=欄位名稱.length-1) sql+=" or "
}
這樣也不失一種作法 :P
--
找不到簡單的作法的時候 試試複雜的做法也不賴 :P
--
String temp="relax"; | Life just like programing
while(buringlife) String.forgot(temp); | to be right or wrong
while(sleeping) brain.setMemoryOut(); | need not to say
stack.push(life.running); | the complier will
stack.push(scouting.buck()); | answer your life
stack.push(bowling.pratice()); | Bone everything
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.138.240.58