On 9/7/07, Brad Stiles <[EMAIL PROTECTED]> wrote:
>
> Anyway, if I understand what you're saying, I believe what you want is an
> OUTER JOIN.
>
> SELECT    T1.COLUMN, T2.COLUMN
> FROM      TABLE2 T2
>          outer join TABLE1 T1 on T2.COLUMN = T1.COLUMN
>
> That will get all rows from T2, and matching rows from T1.  If no row in
> T1 exists, then T1.COLUMN will be null.


Thanks for pointing me in the right direction.  I created a test database
and tables, and was able to figure it out.  Turns out LEFT JOIN does exactly
what I was looking for.  I'm pasting in the text below just in case anyone
else finds it useful (the concept more than the SQL syntax).

DROP TABLE ACCOUNT;
DROP TABLE IMPORT;
CREATE TABLE ACCOUNT(PKEY VARCHAR(10));
CREATE TABLE IMPORT(PKEY VARCHAR(10));

INSERT INTO ACCOUNT VALUES('E000000001');
INSERT INTO ACCOUNT VALUES('E000000002');
INSERT INTO ACCOUNT VALUES('E000000003');
INSERT INTO ACCOUNT VALUES('E000000004');
INSERT INTO ACCOUNT VALUES('E000000005');

INSERT INTO IMPORT VALUES('E000000001');
INSERT INTO IMPORT VALUES('E000000006');
INSERT INTO IMPORT VALUES('E000000003');
INSERT INTO IMPORT VALUES('E000000007');
INSERT INTO IMPORT VALUES('E000000005');

SELECT T1.PKEY, T2.PKEY FROM IMPORT T2 LEFT JOIN ACCOUNT T1 ON T2.PKEY =
T1.PKEY;

Thanks again for the tip.

Reply via email to