0

I am trying to get the data from the three table using inner join but its sows me empty result.

select comp.gps_time as complaint_register_date,comp.accept_date as complaint_accept_date,comp.name as citizen_name,comp.road_id,dept.dept_name,circle.circle_name,division.div_name 
from complaints as comp 
 INNER JOIN department as dept ON dept.dept_code=comp.dept_code 
 INNER JOIN circle as circle on circle.circle_code=comp.circle_code 
 INNER JOIN division as division on division.div_code=comp.div_code 
where comp.templateid != null

complaint table

Complaint_Id Roadid Dept_code Div_code Circle_code Name Templateid Accept_date Gps_time
162 167889 3 1 4 Xyz 3 2019年02月25日 09:40:39 2019年02月23日 09:40:39
168 167880 2 4 6 abc null 2019年02月25日 09:40:39 2019年02月23日 09:40:39

Department table

Dept_code Dept_name
3 Abcdept
2 Zyzdept
1 syzdept

Circle table

Circle_code Circle_name
4 Xcircle
6 ycircle

Division Table

Division_code Division_name
1 Ydiv
2 ndiv
4 zdiv
asked May 9, 2019 at 10:47

1 Answer 1

0

You can't test for null using = or <> (or !=)

To test for non-null values you need to use IS NOT NULL:

where comp.templateid is not null
answered May 9, 2019 at 10:58

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.