Outer joins have always managed to confuse me. Could you help with this?
SQL> DROP TABLE ACTIVITY_TEST;
Table dropped.
SQL> CREATE TABLE ACTIVITY_TEST (
2 ACTIVITY_ID NUMBER,
3 NAME VARCHAR2 (30),
4 MORDER NUMBER (3),
5 BGCOLOR VARCHAR2 (7),
6 TEXT_COLOUR VARCHAR2 (7) ) ;
Table created.
SQL> INSERT INTO ACTIVITY_TEST ( ACTIVITY_ID, NAME, MORDER, BGCOLOR,
2 TEXT_COLOUR ) VALUES (
3 1, 'Key Kids events', 1, '#9999CC', '#000000');
1 row created.
SQL> DROP TABLE EVENT_TEST;
Table dropped.
SQL> CREATE TABLE EVENT_TEST (
2 ID NUMBER NOT NULL,
3 START_DATE DATE,
4 END_DATE DATE,
5 GROUP_ID NUMBER,
6 FRANCHISE_ID NUMBER,
7 ACTIVITY_ID NUMBER,
8 USER_ID NUMBER,
9 PLACE VARCHAR2 (50),
10 NOTES VARCHAR2 (2000),
11 LAST_UPDATED DATE,
12 COUNTRY_ID VARCHAR2 (4),
13 ACTIVITY_NAME VARCHAR2 (100),
14 TIME VARCHAR2 (30),
15 TASKFORCE_ID NUMBER ) ;
Table created.
SQL> INSERT INTO EVENT_TEST ( ID, START_DATE, END_DATE, GROUP_ID, FRANCHISE_ID, ACTIVITY_ID, USER_ID,
2 PLACE, NOTES, LAST_UPDATED, COUNTRY_ID, ACTIVITY_NAME, TIME, TASKFORCE_ID ) VALUES (
3 1011, TO_Date( '10/01/2002 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'), TO_Date( '10/01/2002 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM')
4 , 3, 0, 1, 360, NULL, NULL, TO_Date( '01/23/2002 06:16:34 PM', 'MM/DD/YYYY HH:MI:SS AM')
5 , '1', 'Halloween', NULL, NULL);
1 row created.
SQL> INSERT INTO EVENT_TEST ( ID, START_DATE, END_DATE, GROUP_ID, FRANCHISE_ID, ACTIVITY_ID, USER_ID,
2 PLACE, NOTES, LAST_UPDATED, COUNTRY_ID, ACTIVITY_NAME, TIME, TASKFORCE_ID ) VALUES (
3 6222, TO_Date( '10/12/2002 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'), TO_Date( '10/12/2002 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM')
4 , 3, 1, 1, 101, NULL, NULL, TO_Date( '06/19/2002 02:01:45 PM', 'MM/DD/YYYY HH:MI:SS AM')
5 , '1', 'Great Activity', NULL, NULL);
1 row created.
SQL> DROP TABLE COUNTRY;
Table dropped.
SQL> CREATE TABLE COUNTRY (
2 COUNTRY_ID VARCHAR2 (4),
3 COUNTRY VARCHAR2 (30),
4 IMAGE_NAME VARCHAR2 (30),
5 ALT_NAME VARCHAR2 (20),
6 SHORT_CODE VARCHAR2 (3) );
Table created.
SQL> INSERT INTO COUNTRY ( COUNTRY_ID, COUNTRY, IMAGE_NAME, ALT_NAME,
2 SHORT_CODE ) VALUES (
3 '1', 'United Kingdom', 'uk_flag_curve.gif', 'United Kingdom', 'UK');
1 row created.
SQL> INSERT INTO COUNTRY ( COUNTRY_ID, COUNTRY, IMAGE_NAME, ALT_NAME,
2 SHORT_CODE ) VALUES (
3 '2', 'France', 'france_flag_curve.gif', 'France', 'FR');
1 row created.
SQL> INSERT INTO COUNTRY ( COUNTRY_ID, COUNTRY, IMAGE_NAME, ALT_NAME,
2 SHORT_CODE ) VALUES (
3 '3', 'Germany', 'gsa_flag_curve.gif', 'GSA', 'DE');
1 row created.
SQL> INSERT INTO COUNTRY ( COUNTRY_ID, COUNTRY, IMAGE_NAME, ALT_NAME,
2 SHORT_CODE ) VALUES (
3 '4', 'Spain', 'iberia_flag_curve.gif', 'Iberia', 'ES');
1 row created.
SQL> INSERT INTO COUNTRY ( COUNTRY_ID, COUNTRY, IMAGE_NAME, ALT_NAME,
2 SHORT_CODE ) VALUES (
3 '5', 'Belgium', 'benelux_flag_curve.gif', 'Benelux', 'BE');
1 row created.
SQL> INSERT INTO COUNTRY ( COUNTRY_ID, COUNTRY, IMAGE_NAME, ALT_NAME,
2 SHORT_CODE ) VALUES (
3 '6', 'Switzerland', 'gsa_flag_curve.gif', 'GSA', 'CH');
1 row created.
SQL> INSERT INTO COUNTRY ( COUNTRY_ID, COUNTRY, IMAGE_NAME, ALT_NAME,
2 SHORT_CODE ) VALUES (
3 '7', 'Sweden', 'nordic_flag_curve.gif', 'Nordic', 'SE');
1 row created.
SQL> INSERT INTO COUNTRY ( COUNTRY_ID, COUNTRY, IMAGE_NAME, ALT_NAME,
2 SHORT_CODE ) VALUES (
3 '8', 'Norway', 'nordic_flag_curve.gif', 'Nordic', 'NO');
1 row created.
SQL> INSERT INTO COUNTRY ( COUNTRY_ID, COUNTRY, IMAGE_NAME, ALT_NAME,
2 SHORT_CODE ) VALUES (
3 '9', 'Netherlands', 'benelux_flag_curve.gif', 'Benelux', 'NL');
1 row created.
SQL> INSERT INTO COUNTRY ( COUNTRY_ID, COUNTRY, IMAGE_NAME, ALT_NAME,
2 SHORT_CODE ) VALUES (
3 '10', 'Luxembourg', 'benelux_flag_curve.gif', 'Benelux', 'LU');
1 row created.
SQL> INSERT INTO COUNTRY ( COUNTRY_ID, COUNTRY, IMAGE_NAME, ALT_NAME,
2 SHORT_CODE ) VALUES (
3 '11', 'Italy', 'italy_flag_curve.gif', 'Italy', 'IT');
1 row created.
SQL> INSERT INTO COUNTRY ( COUNTRY_ID, COUNTRY, IMAGE_NAME, ALT_NAME,
2 SHORT_CODE ) VALUES (
3 '12', 'Finland', 'nordic_flag_curve.gif', 'Nordic', 'FI');
1 row created.
SQL> INSERT INTO COUNTRY ( COUNTRY_ID, COUNTRY, IMAGE_NAME, ALT_NAME,
2 SHORT_CODE ) VALUES (
3 '13', 'Denmark', 'nordic_flag_curve.gif', 'Nordic', 'DK');
1 row created.
SQL> INSERT INTO COUNTRY ( COUNTRY_ID, COUNTRY, IMAGE_NAME, ALT_NAME,
2 SHORT_CODE ) VALUES (
3 '0', 'Europe', 'europe_flag_curve.gif', 'Europe', NULL);
1 row created.
SQL> INSERT INTO COUNTRY ( COUNTRY_ID, COUNTRY, IMAGE_NAME, ALT_NAME,
2 SHORT_CODE ) VALUES (
3 '100', 'None', NULL, NULL, NULL);
1 row created.
SQL> INSERT INTO COUNTRY ( COUNTRY_ID, COUNTRY, IMAGE_NAME, ALT_NAME,
2 SHORT_CODE ) VALUES (
3 '14', 'Poland', 'poland_flag_curve.gif', NULL, 'PL');
1 row created.
SQL> INSERT INTO COUNTRY ( COUNTRY_ID, COUNTRY, IMAGE_NAME, ALT_NAME,
2 SHORT_CODE ) VALUES (
3 '15', 'Austria', 'gsa_flag_curve.gif', 'GSA', 'AT');
1 row created.
SQL> INSERT INTO COUNTRY ( COUNTRY_ID, COUNTRY, IMAGE_NAME, ALT_NAME,
2 SHORT_CODE ) VALUES (
3 '16', 'Emerging Markets', 'emerging_flag_curve.gif', 'Emerging Markets', NULL);
1 row created.
SQL> INSERT INTO COUNTRY ( COUNTRY_ID, COUNTRY, IMAGE_NAME, ALT_NAME,
2 SHORT_CODE ) VALUES (
3 '17', 'Portugal', 'iberia_flag_curve.gif', 'Iberia', 'PO');
1 row created.
SQL> DROP TABLE FRANCHISE_TEST;
Table dropped.
SQL> CREATE TABLE FRANCHISE_TEST (
2 ID NUMBER,
3 NAME VARCHAR2 (50),
4 BGCOLOR VARCHAR2 (10),
5 XLOB VARCHAR2 (1) NOT NULL,
6 CALENDAR VARCHAR2 (1) NOT NULL ) ;
Table created.
SQL> INSERT INTO FRANCHISE_TEST ( ID, NAME, BGCOLOR, XLOB, CALENDAR ) VALUES (
2 1, 'Franchise 1', '#FFFF33', 'N', 'Y');
1 row created.
SQL> INSERT INTO FRANCHISE_TEST ( ID, NAME, BGCOLOR, XLOB, CALENDAR ) VALUES (
2 0, 'None', '#FFFFFF', 'N', 'Y');
1 row created.
SQL> commit;
Commit complete.
SQL> insert into activity_test Values(2,'School Events',2,'#FF9999','#000000');
1 row created.
SQL> commit;
Commit complete.
SQL> col name format a20
SQL> col activity_name format a20
SQL> select a.name, e.activity_name
2 from activity_test a, event_test e
3* WHERE a.activity_id = e.activity_id
NAME ACTIVITY_NAME
-------------------- --------------------
Key Kids events Halloween
Key Kids events Great Activity
SQL> ed
Wrote file afiedt.buf
1 select a.name, e.activity_name
2 from activity_test a, event_test e
3* WHERE a.activity_id = e.activity_id(+)
SQL> /
NAME ACTIVITY_NAME
-------------------- --------------------
Key Kids events Halloween
Key Kids events Great Activity
School Events
SQL> ed
Wrote file afiedt.buf
1 select a.name, e.activity_name, f.bgcolor
2 from activity_test a, event_test e, country c, franchise_test f
3 WHERE a.activity_id = e.activity_id(+)
4 AND c.country_id = e.country_id
5* AND e.franchise_id = f.id
SQL> /
NAME ACTIVITY_NAME BGCOLOR
-------------------- -------------------- ----------
Key Kids events Halloween #FFFFFF
Key Kids events Great Activity #FFFF33
What I really need to see is the entry for School events with nulls for the activity_name and BGCOLOR, but adding the extra tables seem to "lose" them!!