select * from <@PREFIX@>vm_product_relations where LOCATE('|',related_products) = 0
and product_id = <@KEY@>
union
select product_id ,replace(substring(substring_index(related_products , '|' , 1), length(substring_index(related_products , '|', 0)) - -1), '|' , '')   from <@PREFIX@>vm_product_relations where 
replace(substring(substring_index(related_products , '|' , 1), length(substring_index(related_products , '|', 0)) - -1), '|' , '')   <> '' 
and product_id = <@KEY@>
union
select product_id ,replace(substring(substring_index(related_products , '|' , 2), length(substring_index(related_products , '|', 1)) - -1), '|' , '')   from <@PREFIX@>vm_product_relations where 
replace(substring(substring_index(related_products , '|' , 2), length(substring_index(related_products , '|', 1)) - -1), '|' , '')   <> '' 
and product_id = <@KEY@>
union
select product_id ,replace(substring(substring_index(related_products , '|' , 3), length(substring_index(related_products , '|', 2)) - -1), '|' , '')   from <@PREFIX@>vm_product_relations where 
replace(substring(substring_index(related_products , '|' , 3), length(substring_index(related_products , '|', 2)) - -1), '|' , '')   <> '' 
and product_id = <@KEY@>
union
select product_id ,replace(substring(substring_index(related_products , '|' , 4), length(substring_index(related_products , '|', 3)) - -1), '|' , '')   from <@PREFIX@>vm_product_relations  where 
replace(substring(substring_index(related_products , '|' , 4), length(substring_index(related_products , '|', 3)) - -1), '|' , '')   <> '' 
and product_id = <@KEY@>

