
CREATE VIEW [dbo].[SPICE_TaxonID2HigherTaxonID_VIEW]
AS
SELECT     dbo.PTaxon.RIdentifier AS TaxonID, PTaxon_Higher.RIdentifier AS HigherTaxonID, dbo.Name.RankFk
FROM         dbo.PTaxon INNER JOIN
                      dbo.RelPTaxon ON dbo.PTaxon.PTNameFk = dbo.RelPTaxon.PTNameFk1 AND dbo.PTaxon.PTRefFk = dbo.RelPTaxon.PTRefFk1 INNER JOIN
                      dbo.PTaxon PTaxon_Higher ON dbo.RelPTaxon.PTNameFk2 = PTaxon_Higher.PTNameFk AND 
                      dbo.RelPTaxon.PTRefFk2 = PTaxon_Higher.PTRefFk INNER JOIN
                      dbo.Name ON dbo.PTaxon.PTNameFk = dbo.Name.NameId
WHERE     (dbo.RelPTaxon.RelQualifierFk = 1) 


GO
