Forums Register Login

where clause

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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...
+Pie Number of slices to send: Send
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 ]
+Pie Number of slices to send: Send
thanks for replying,
+Pie Number of slices to send: Send
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,
We're being followed by intergalactic spies! Quick! Take this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 799 times.
Similar Threads
jini for dist. programing
encodeURIComponent is not working in IE8
on board LAN disabled in slackware
how to create tab pane in jsf
while mailing through yahoo i use http or smtp
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 21:35:34.