mikaelsnavy of CaseTrakker Dynamo Snips
6/9/2016 - 6:13 PM

Finds all objects where a certain code is used

Finds all objects where a certain code is used

SELECT
	ct_type.name AS type_name,
	ct_type.ct_id AS type_id,
	relation.name AS code_name,
	relation.ct_id AS code_id
FROM
	ct_rlink
INNER JOIN ct_type
	ON ct_type.ct_id = ct_rlink.source_id
INNER JOIN ct_type relation
	ON relation.ct_id = ct_rlink.rtype_id
	AND relation.ct_id = '{013D6403-C970-4BAB-90D7-27E7BA76A5C9}'
SELECT
	ct_type.name AS type_name,
	ct_type.ct_id AS type_id,
	ct_ptype.name AS code_name,
	ct_ptype.ct_id AS code_id
FROM
	ct_plink
INNER JOIN ct_type
	ON ct_type.ct_id = ct_plink.source_id
INNER JOIN ct_ptype
	ON ct_ptype.ct_id = ct_plink.ptype_id
	AND ct_ptype.ct_id = '{a6434c7c-326c-4f6d-bd7c-509b1ac8950c}'