I want muliti table join.it’s show 1 data/show 2 record But really 1 data/1 record.
select acl.Person_ID as 'CODE'
,pnr.FullName as 'FullName'
,case acl.persontype when 'normal' then 'normal' end as 'Type'
From tbl_aculog acl left join tbl_PerNR pnr On acl.Person_ID=pnr.Person_ID
union
select acl.Person_ID as 'CODE'
,ps.FullName as 'FullName'
,case acl.persontype when 'blacklist' then 'blacklist' end as 'Type'
From tbl_aculog acl left join tbl_Person ps On acl.Person_ID=ps.NPerson_ID
Result:
Person_ID | FullName | Type 00010132 | Stin| normal 00010132 | NULL | NULL 00000579 | Plom | normal 00000579 | NULL | NULL 00001081 | Watson | normal 00001081 | NULL | NULL 5211080 | SOPIT | blacklist 5211080 | NULL | NULL
**Fields Person_ID & FullName & Type is NULL VALUE.
I want Result:
Person_ID | FullName | Type 00010132 | Stin| normal 00000579 | Plom | normal 00001081 | Watson | normal 5211080 | SOPIT | blacklist
Thank you very much for your time 😀
To remove
NULLs from your result, you need to specifyWHERE acl.persontype IS NOT NULLto ignore empty ‘persontype’.Edit 1
The use of an
INNER JOINwill removeNULLS.