To do a join and get half a result even if the other record does not exist, use an outer join.
To chose the first non-NULL value of a list, use COALESCE:
SELECT IDowner as IDoutput,
COALESCE(FirstName || ' ' || LastName, CompanyName) AS Name
FROM Owner
LEFT JOIN Contacts ON Owner.IDcontacts = Contacts.IDcontacts
LEFT JOIN Company ON Owner.IDcompany = Company .IDcompany
0
solved Concatenate as A and choose either A or B according to their FKs [closed]