Rows of Suppliers can come from People or Companies linked by ID. TYPE distinguishes the difference. If TYPE = 0, ID is in People, otherwise, it’s in Companies.
I would like to create a View. If it is not possible in View, can it be solved using a Stored Procedure? How?
Select a.Type, b.Name
from Suppliers a, People b
where a.type = b.ID and a.type = 0
UNION
Select x.Type, y.Name
from Suppliers x, Companies y
where x.type = y.ID and a.type <> 0;
Select a.Type, b.Name
from Suppliers a, People b
where a.type = b.ID and a.type = 0
UNION
Select x.Type, y.Name
from Suppliers x, Companies y
where x.type = y.ID and a.type <> 0
ORDER BY b.name