Database View-Where Clause Not working

chaitanyaya
Tera Contributor

Team,

I am creating database view for two tables. cmdb_ci_hardware & Problem records with left join. 

It should show for how many CIs problem was raised plus rest of CIs (with no any problem ticket raise)

 

But its not showing any records.

 

chaitanyaya_0-1721193763702.png

 

1 ACCEPTED SOLUTION

Mark Manders
Mega Patron

Shouldn't it be 'hwd_sys_id=prb_cmdb_ci'? You are checking if the sys_id of the CI is the same as the sys_id of the problem. That will never be the case.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

View solution in original post

6 REPLIES 6

Yashsvi
Kilo Sage

Hi @chaitanyaya,

please check below link:

https://www.servicenow.com/community/developer-forum/where-clause-on-database-view-not-working/m-p/1...

Thank you, please make helpful if you accept the solution.

Mark Manders
Mega Patron

Shouldn't it be 'hwd_sys_id=prb_cmdb_ci'? You are checking if the sys_id of the CI is the same as the sys_id of the problem. That will never be the case.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Hi @Mark Manders 

Thanks. Its working & showing records from hardware table for which problem is raised.  

But left join not working. (Like its not showing all recrods)

chaitanyaya_0-1721293656929.png

 

Community Alums
Not applicable

Hi @chaitanyaya ,

SysId of problem table and hardware table is never be the same , you should take some other variable instead sys_id like I did with assigned_to 

Hardware_assigned_to= Problem_assigned_to

SarthakKashyap_0-1721199857671.png

 

Result 

SarthakKashyap_1-1721199877846.png

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards 

Sarthak