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

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

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 January 23rd, 2013, 10:02 AM
fee1975 fee1975 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 76 fee1975 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 42 m 42 sec
Reputation Power: 6
Handling NULL values

I have 2 tables, AFF_TEMP and COUNTY
AFF_TEMP has the following columns FNAME, LNAME, EMAIL and COUNTY
COUNTY has 2 columns COUNTY_ID and CNAME

Both tables have the following test data
AFF_TEMP
Joe, Bloggs, joe@gmail.com, ''
Ann, Bloggs, anne@gmail.com,Donegal

and COUNTY column in AFF_TEMP can contain a NULL value

County table has the following Test data,
1, Dublin
2, Donegal
3, Tipperary,
4, Galway


I am trying to select the following from both tables FNAME, LNAME, EMAIL, COUNTY_ID.
Tried the following queries
select a.FNAME, a.LNAME,a.EMAIL, C.COUNTY_ID FROM temp_aff A LEFT OUTER JOIN COUNTY C ON A.COUNTY=C.CNAME
OR (A.COUNTY IS NULL)

select a.FNAME, a.LNAME,a.EMAIL, C.COUNTY_ID FROM temp_aff A, COUNTY C
WHERE C.CNAME IN (SELECT UPPER(A.COUNTY) FROM TEMP_AFF A)
or A.COUNTY IS null

but cant get it to work....
This should be my output
Joe, Bloggs, joe@gmail.com, null
Ann, Bloggs, anne@gmail.com,6

Appreciate any help on this!

Last edited by fee1975 : January 23rd, 2013 at 10:18 AM.

Reply With Quote
  #2  
Old January 23rd, 2013, 03:40 PM
spacebar208's Avatar
spacebar208 spacebar208 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2012
Location: spaceBAR Central
Posts: 203 spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 16 h 10 sec
Reputation Power: 41
Post the results of these queries:
Code:
select *
 from  temp_aff

select *
 from  county

select a.fname, a.lname, a.email, nvl( c.county_id, '** No Match found' ) as county_id
 from  temp_aff a left outer join county c on a.county  =  c.cname

select a.fname, a.lname, a.email, nvl( c.county_id, '** No Match found' ) as county_id
 from  temp_aff a left outer join county c on trim( lower( a.county ) )  =  trim( lower( c.cname ) )

Reply With Quote
  #3  
Old January 24th, 2013, 03:45 AM
fee1975 fee1975 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 76 fee1975 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 42 m 42 sec
Reputation Power: 6
Results from first Query
Code:
Corcoran	Sean	sean@dit.ie 	095-742842 HP			
Fallon	 Declan	declan.fallon@hotmail.co.uk	091-742842	HP			
Douglas	Lorna	lorna.douglas@gmail.com	091-787904				Limerick


Results from second query
Code:
1	TIPPERARY
2	LOUTH
3	CLARE
4	DUBLIN
5	GALWAY
6	LIMERICK


Results form 3rd query
Code:
Declan	Fallon Declan.fallon@hotmail.co.uk	** No Match found
Sean	Corcoran	sean@dit.ie	** No Match found
Lorna	Douglas	lorna.douglas@gmail.com	** No Match found


And 4th query results
Code:
Lorna	Douglas	lorna.douglas@gmail.com	6
Declan	Fallon	declan.fallon@hotmail.co.uk	** No Match found
Sean	Corcoran	sean@dit.ie	** No Match found

Reply With Quote
  #4  
Old January 24th, 2013, 06:04 AM
fee1975 fee1975 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 76 fee1975 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 42 m 42 sec
Reputation Power: 6
Got it working thanks

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Handling NULL values

Developer Shed Advertisers and Affiliates



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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap