-- ============================================================
-- taxonomy_regulation_lookup
-- ============================================================
SELECT
	trr.taxonomy_regulation_id AS value_member,
(ISNULL(g.state, 'Country-wide')) + ', ' + g.country + ': ' + trr.regulation_type_code + ', ' + trr.regulation_level AS display_member

	--ISNULL(g.state, 'Country-wide)') + ', ' + g.country + ': ' + trr.regulation_type_code + ', ' + trr.regulation_level AS display_member
  FROM 
	taxonomy_ref_regulation trr
  INNER JOIN
	geo g
  ON
	trr.geography_id = g.geono
WHERE
 trr.regulation_level IS NOT NULL
AND
 ((trr.created_date > COALESCE(:createddate, '1753-01-01'))
   OR (trr.modified_date > COALESCE(:modifieddate, '1753-01-01'))
   OR (trr.taxonomy_regulation_id IN (:valuemember))
   OR (trr.taxonomy_regulation_id  BETWEEN :startpkey AND :stoppkey)
 )

-- ============================================================
-- get_taxonomy_regulation_map
-- ============================================================
SELECT  trm.taxonomy_regulation_map_id
      ,taxonomy_family_id
      ,taxonomy_genus_id
      ,taxonomy_species_id
      ,taxonomy_regulation_id
      ,note
      ,created_date
      ,created_by
      ,modified_date
      ,modified_by
      ,owned_date
      ,owned_by
  FROM gringlobal.dbo.taxonomy_regulation_map trm
  INNER JOIN
  (SELECT  
	taxonomy_regulation_map_id
   FROM 
		taxonomy_regulation_map
	 WHERE
	 taxonomy_regulation_map_id IN (:taxonomyregulationmapids)) list ON
	 list.taxonomy_regulation_map_id = trm.taxonomy_regulation_map_id