my query is ("select * from table1 where field1=? and field2=? and field3=? and(field4=? or field5=?") when i use only 'and' once it is working but when i use multiple 'and's & 'or's it is not working ,it does'nt give any exception.
What do you mean by "it's not working"? What is the data in the table, what are you setting for the parameters etc. We need more code to be able to work out what's going on...
Could it be as simple as: ("select * from table1 where field1=? and field2=? and field3=? and (field4=? or field5=?)") In your example you have opening and closing parenthesis around the entire query, but you are missing a closing parenthesis around the two fields in the "OR" part of the clause. You might also want to put a space between the last "and" and the opening parenthesis. [ March 08, 2004: Message edited by: Wayne L Johnson ]
thanks for replying, here is my code stat=con.prepareStatement("Select uid from Table1 where qualification=? and location=? and experience=? and salary_range=? and ( skill1=? or skill2=? or skill3=? or skill4=?)"); stat.setString(1,quali2); stat.setString(2,loc2); stat.setString(3,exp2); stat.setString(4,salr2); stat.setString(5,skill21); stat.setString(6,skill22); stat.setString(7,skill23); stat.setString(8,skill24);
result=stat.executeQuery();
while(result.next()) { System.out.println("uid="+result.getString(1)); } ----it does'nt give any result means it can'nt find any record satisfying these criateria, but many records satisfying these conditions are there in database. when i use 'and' once it works, it shows records, but when i use 'and' even twice(also when i use multiple 'and's &'or's) it does'nt give any records,
Post by:autobot
We're being followed by intergalactic spies! Quick! Take this tiny ad!
a bit of art, as a gift, the permaculture playing cards