dan@hrc.uucp (Dan Troxel) (05/07/91)
How do I get all records from table_1, even though some records in table_1 are not linked to table_2??? select table_1.field_1, table_2.field_2 from table_1, table_2 where table_1.field_1 = table_2.field_1 This will pull only those records that match in both tables per the where clause. I want to get all records in table_1, whether or not they match any records in table_2. So that I might get an end result as follows: table_1.field_1 | table_2.field_2 ----------------------------------------------------------------- 3001 | linked note... 3002 | linked note.... 3003 | 3004 | linked note.... 3005 | instead of: table_1.field_1 | table_2.field_2 ----------------------------------------------------------------- 3001 | linked note... 3002 | linked note.... 3004 | linked note.... Any help *will* be appreciated. -- Dan Troxel @ Handwriting Research Corporation WK 1-602-957-8870 Camelback Corporate Center 2821 E. Camelback Road Suite 600 Phoenix, AZ 85016 ncar!noao!asuvax!hrc!dan zardoz!hrc!dan hrc!dan@asuvax.eas.asu.edu
hansene@hpcc01.HP.COM (Ed Hansen) (05/13/91)
/ hpcc01:comp.databases / dan@hrc.uucp (Dan Troxel) / 5:04 pm May 6, 1991 / How do I get all records from table_1, even though some records in table_1 are not linked to table_2??? select table_1.field_1, table_2.field_2 from table_1, table_2 where table_1.field_1 = table_2.field_1 /******************************************************************/ What you need here is an 'Outer Join' and I don't think this is available in Unify. In SYBASE , your query will be as follows : select table_1.field_1, table_2.field_2 from table_1, table_2 where table_1.field_1 *= table_2.field_1 Another way of achieving this result is by using UNION (again not supported by Unify ? ) as follows : select table_1.field_1, table_2.field_2 from table_1, table_2 where table_1.field_1 = table_2.field_1 union select table_1.field_1, NULL from table_1 where table_1.field_1 not in (select table_2.field_1 from table_2) JeanMarie (jeanmar@hpcc31.corp.hp.com) /*****************************************************************/