I have two tables: scans
and personel
. In scans
there is a column createdby
where the username of the person who created a scan is there. I need to create a view where to see these scans but instead of the username, I want to see the full name of that person which I have in the table personel
. This query mostly works:
select personel.firstname ||' '|| personel.lastname as CREATEDBY
from scans inner join personel on scans.createdby = personel.username;
The problem is that there are some user names in scans.createdby
which aren't anymore in the personel
table and their scans are not retrieved by the above query since the values in the createdby
column does not match with any value in the username
column.
So for that case, I would like to output the value from createdby
for those scans.
So if:
scans.createdby = personel.username
=> show full name
but if:
scans.createdby
doesn't match any personel.username
=> show username from scans.createdby
instead of full name