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:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old February 1st, 2005, 07:02 PM
paulh1983 paulh1983 is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Dec 2004
Posts: 1,229 paulh1983 User rank is Sergeant (500 - 2000 Reputation Level)paulh1983 User rank is Sergeant (500 - 2000 Reputation Level)paulh1983 User rank is Sergeant (500 - 2000 Reputation Level)paulh1983 User rank is Sergeant (500 - 2000 Reputation Level)paulh1983 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 10 h 25 m 27 sec
Reputation Power: 17
UNION/select query, returns an error -solved

Never mind! solved

This is how my table looks like:
Code:
 
Name                                      Null?    Type
 ----------------------------------------- -------- -------------
 OPPONENT                                           VARCHAR2(25)
 MATCH_DATE                                         DATE
 MATCH_TIME                                         VARCHAR2(10)
 LOCATION                                           VARCHAR2(20)
 LEAGUE                                             VARCHAR2(30)


this is what my query is:
Code:
select *from ( 
select 'Charlton vs '||Opponent as Team, match_date, Match_time, Location, League from charlton_games@charlton1 UNION 
select 'Liverpool vs '||Opponent as Team, match_date, Match_time, Location, League from liverpool_games@liverpool1 UNION 
select 'Portsmouth vs '||Opponent as Team, match_date, Match_time, Location, League from portsmouth_games@portsmouth1 UNION 
select 'Man U vs '||Opponent as Team, match_date, Match_time, Location, League from man_u_games@man_u1) 
where opponent = 'Everton' and Match_Date>Sysdate
Order by Match_Date;


but it gives me an error on opponent in the where clause!

Reply With Quote
  #2  
Old February 2nd, 2005, 02:11 AM
shammat shammat is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2003
Location: Munich, Bavaria
Posts: 971 shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 44 m 25 sec
Reputation Power: 57
That's because the derived table (the "inner" select) does not have a LoCATION column. The inner select returns a result set that has two columns: one named team the other named match_date.

If you want to limit to location = 'HOME' you need to include that in every single select for the UNION or it to the inner select.
Code:
SELECT team, match_date
FROM (      
      SELECT 'Charlton vs ' ||opponent AS team,
             match_date, 
             location
      FROM charlton_games@charlton1
      UNION
      SELECT 'Liverpool vs ' ||opponent AS team,
             match_date, 
             location
      FROM liverpool_games@liverpool1
      UNION
      SELECT 'Portsmouth vs ' ||opponent AS team,
             match_date, 
             location
      FROM portsmouth_games@portsmouth1
      UNION
      SELECT 'Crystal Palace vs ' ||opponent AS team,
             match_date, 
             location
      FROM palace_games@palace1
      UNION
      SELECT 'MAN U vs ' ||opponent AS team,
             match_date, 
             location
      FROM man_u_games@man_u1
      )
WHERE location = 'Home';

Reply With Quote
  #3  
Old February 2nd, 2005, 11:08 AM
paulh1983 paulh1983 is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Dec 2004
Posts: 1,229 paulh1983 User rank is Sergeant (500 - 2000 Reputation Level)paulh1983 User rank is Sergeant (500 - 2000 Reputation Level)paulh1983 User rank is Sergeant (500 - 2000 Reputation Level)paulh1983 User rank is Sergeant (500 - 2000 Reputation Level)paulh1983 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 10 h 25 m 27 sec
Reputation Power: 17
Never mind!

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > UNION/select query, returns an error


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 4 hosted by Hostway