Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Left join is not working for database view

Vijay Talupula
Tera Guru

Guys,

I have created a DB view for User Vs User Role table in my personal instance. I have turned on left join checkbox and it is working as expected.

But the same thing when I try in my client dev instance it is giving only matching records but not all the records. Please see the below screen shots for reference.

find_real_file.png

And it is giving 2511 records which is User role table count where as User table is having 26k+ records. I am not sure what I am missing here tough created similarly how I did in my personal dev instance.

Note: Both are Istanbul versions but personal instance is patch5 and client instance is patch3 instance. Not sure whether it is causing the issue.

1 ACCEPTED SOLUTION

Can you make these change and tell me if this is what you are looking for?



View table -> sys_user - order-100 - where-user_sys_id=role_user - Left join-True


View table -> sys_user_has_role - order-200   - Left join-True


View solution in original post

9 REPLIES 9

snehabinani26
Tera Guru

HI Vijay,



If you want all record of User table then change your where clause to usr_sys_id = role_user.



Hope this helps you


I have already tried that but there was no luck


Kalaiarasan Pus
Giga Sage

First thing, you do not need a database view to join these tables.


You can directly dot-walk the user field and get all the required details of the user using just sys_user_has_role table.



So, do we now need to debug this issue further?


If I do like that I would get only the records available in User Roles table but I am looking to get all the User records with roles from User table. Thats the reason I am using database view Kalai. Hope you got my requirement clearly.