nutty
nutty

Reputation: 67

How to do NOT NULL check in mysql query

Please find below query.

select * from table tab1,
table tab2,
table tab3
where tab1.sid = tab2.sid
and tab2.referencedid = tab3.referencedid

My requirement is tab3's column value which tab3.referencedid is not then use the and condition and populate the records. Please suggest me a way how to achieve this. Based on NOT NULL condition query results should be obtained

Upvotes: 1

Views: 2827

Answers (2)

The Reason
The Reason

Reputation: 7973

As i understand you in this case better to use JOIN instend of using join in Where clause

SELECT  * 
FROM   table1 t1
  JOIN table2 t2  ON t1.sid = t2.sid
  JOIN table3 t3 ON t2.referencedid = t3.referencedid
WHERE  // here you can add your criteria if you have

Upvotes: 1

ekawas
ekawas

Reputation: 6654

The syntax for the IS NOT NULL Condition in MySQL is:

field IS NOT NULL

Upvotes: 2

Related Questions