Home > Blockchain >  How to evaluate two tables column cell values?
How to evaluate two tables column cell values?

Time:09-04

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.

CodePudding user response:

Try this:

SELECT customerID, customerNumber 
FROM customerTable 
     LEFT JOIN receiptTable  ON customerID = customerNumber
WHERE customerNumber is NULL
  •  Tags:  
  • sql
  • Related