Do a left join to the parent table on the key in question, then examine the values in the child table where the value in the left-joined parent table are null.

For example, if this was your schema...

table1:
    myKey int primary key,
    ...other columns...

table2:
    otherKey int primary key,
    myKeyFromTable1 int
    ...other columns...


You'd do this:

select distinct
    t2.myKeyFromTable1

from table2 t2

left join table1 t1 on t1.myKey = t2.myKeyFromTable1

where t1.myKey is null


That would give you the distinct values in table2 that wouldn't have a corresponding parent in table1.

Finding columns that do not match existing primary key
I have a barcode scanner on one view, and after the user has scanned the barcode, the app takes them to another view (BoilerDetails) where the barcode text field has been pre-filled.

I understand that the viewcontroller is null when it hasn't come into view and I can'tchange the UITextField text directly. This so far has given me an error.. How can I fix this?

BarcodeScannerViewController.m

BoilerDetailsViewController *viewCtrl = [[BoilerDetailsViewController alloc] initWithNibName:nil bundle:nil];
[viewCtrl setBarcode:strBarcode];
[self.navigationController pushViewController:viewCtrl animated:YES];


BoilerDetailsViewController.h

@interface BoilerDetailsViewController : SubViewControllerBase
@property (retain, nonatomic) NSString *barcode;
@property (retain, nonatomic) IBOutlet UITextField *barcodeField;
- (void)setBarcode:(NSString*)strBarcode;
@end


BoilerDetailsViewController.m

-(void)setBarcode:(NSString *)strBarcode
{
    self.barcode = strBarcode;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [_barcodeField setText:self.barcode];
    // Do any additional setup after loading the view from its nib.
}

