3

how can i compare multiple table while checking condition in MySQL?

Cheque Table1

--------------------------
date       |  Cheque_no
--------------------------
10/10/2015 | 09876543
--------------------------
17/10/2015 | 45678990
--------------------------

Payment Table2

----------------------------------------
date       |  Cheque_no  | Amount_Paid
----------------------------------------
10/10/2015 | 09876543    |   1000
----------------------------------------

And I am using the following query:

select * from Cheque,Payment where Cheque.Cheque_no != Payment .Cheque_no 

I am Expecting the output is

17/10/2015 | 45678990
Mureinik
  • 297,002
  • 52
  • 306
  • 350
Dinesh G
  • 1,325
  • 4
  • 17
  • 24
  • 1
    `SELECT some stuff FROM somewhere LEFT JOIN somewhere else ON something = something else WHERE something else IS NULL` – Strawberry Oct 18 '15 at 17:57

1 Answers1

3

Seems like a simple not in condition would do the trick:

SELECT *
FROM   cheque
WHERE  cheque_no NOT IN (SELECT cheque_no FROM payment)
Mureinik
  • 297,002
  • 52
  • 306
  • 350