How to evaluate two tables column cell values?

Viewed 25

I have two tables:

customerTable:

| customerID | name | address | 

receiptTable

| receiptID | customerNumber | products | 

This is my query:

SELECT customerID, customerNumber 
FROM customerTable, receiptTable 
WHERE customerID != customerNumber

What I'm trying to do is get rows of customerID's only if it's not in the receipt table, I really don't even know how to ask this. I apologize.

1 Answers

Try this:

SELECT customerID, customerNumber 
FROM customerTable 
     LEFT JOIN receiptTable  ON customerID = customerNumber
WHERE customerNumber is NULL
Related