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 September 27th, 2005, 09:59 AM
saintaw's Avatar
saintaw saintaw is offline
Lurker - in your bushes
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2000
Location: .be
Posts: 479 saintaw User rank is Second Lieutenant (5000 - 10000 Reputation Level)saintaw User rank is Second Lieutenant (5000 - 10000 Reputation Level)saintaw User rank is Second Lieutenant (5000 - 10000 Reputation Level)saintaw User rank is Second Lieutenant (5000 - 10000 Reputation Level)saintaw User rank is Second Lieutenant (5000 - 10000 Reputation Level)saintaw User rank is Second Lieutenant (5000 - 10000 Reputation Level)saintaw User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 12 h 39 m 8 sec
Reputation Power: 73
OR logic Q?

Hi,

One of the fields in a table is set as VARCHAR ()Typicaly looks like: 1,2,6 or 0,4,5 ... I am basicaly saving options of a form and storing the coldfusion list in the field.

My problem resides when I try to get a select of multiple options...
IE: I want to have a select of all the rows that match either 0 or 4...

The dumbed down query looks like this:
Code:
SELECT EX_ID, EX_FIRST_NAME, EX_LAST_NAME, EX_COUNTRY_LOC, EX_MAIN_TYPE FROM EXPERTS_LIST
 WHERE 1 = 1 
 AND EX_ACTIVE = 1 
 AND (
 	 '999999' IN (EX_MAIN_TYPE)  // This value does not exist, I just used it to start the loop done in CFML
	 OR '0' IN (EX_MAIN_TYPE) 
	 OR '4' IN (EX_MAIN_TYPE)
	 ) 
 ORDER BY LOWER(EX_COUNTRY_LOC), LOWER(EX_LAST_NAME)


My problem is that it returns rows where the value is either 0 or 4, but NOT where both '0' and '4' were saved (IE: 0,4).

I must be missin' something in the 'OR' logic here...
__________________
Saintaw

pending.

Reply With Quote
  #2  
Old September 27th, 2005, 12:39 PM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 1,784 swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 21 h 42 m 49 sec
Reputation Power: 37
Quote:
I must be missin' something in the 'OR' logic here..


It is your database design that is amiss. Never store multiple values in a column. Search for articles on normalization, they abund.

Reply With Quote
  #3  
Old September 28th, 2005, 12:59 AM
saintaw's Avatar
saintaw saintaw is offline
Lurker - in your bushes
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2000
Location: .be
Posts: 479 saintaw User rank is Second Lieutenant (5000 - 10000 Reputation Level)saintaw User rank is Second Lieutenant (5000 - 10000 Reputation Level)saintaw User rank is Second Lieutenant (5000 - 10000 Reputation Level)saintaw User rank is Second Lieutenant (5000 - 10000 Reputation Level)saintaw User rank is Second Lieutenant (5000 - 10000 Reputation Level)saintaw User rank is Second Lieutenant (5000 - 10000 Reputation Level)saintaw User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 12 h 39 m 8 sec
Reputation Power: 73
Yes, I'd personaly have used a reference, and store the values as NUMBER in another table, but I cannot change the DB design.

I think I found a solution though, I was using the above as if they were INTs and I need to treat it as a string... I'll post it when I get in the office.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > OR logic Q?


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 2 hosted by Hostway
Stay green...Green IT