Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 17th, 2005, 01:02 PM
kaihea kaihea is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 34 kaihea User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 13 m 54 sec
Reputation Power: 6
SQL query WHERE question

(cross-posted b/c I'm using Oracle 9i and thought this forum might be of more help than the general database forum)

Hi,

I have a form which produces results that I'd like to search the db with then create another form for further search. My question is, if someone selects to search "all" from the first form, how do I indicate that within the following Select statement? Ie - what value would I give the optionselected so that it picks up all the rows in whichever field?

<code>
<%
//create statement object
Statement stmt = conn.createStatement();

//create resultset object
ResultSet rs = stmt.executeQuery("SELECT * FROM SCHEMA.TABLE where FIELD1 = ('" + optionselecteda + "') and FIELD2 = ('" + optionselectedb + "') and FIELD3 = ('" + optionselectedc + "') and FIELD4 = ('" + optionselectedd + "') ");
%>
</code>

Thank you so much for any help!
Kaihea

Reply With Quote
  #2  
Old March 17th, 2005, 08:11 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 18,231 r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 15 h 46 m 45 sec
Reputation Power: 1054
the best way to handle the "all" scenario is to not generate a conditional test for that field

see The "any" option in dynamic search SQL (site registration may be required, but it's free)
__________________
r937.com | rudy.ca

pre-order my book Simply SQL from Amazon

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > SQL query WHERE question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT