I'm trying to figure out how to remove characters in a string in SQL. The nomenclature that is currently in the database looks like this:
Engine - Brand - Category
How can I remove everything and only leave the 'category' portion?
Funnily enough, the code I've been currently using has been doing the opposite of what I want. It's keeping everything and removing the 'category' portion. I've tried leading, both, and trailing and still get the same results
select trim(Both'-' from SUBSTRING_INDEX(ad_group,'- ',2))
from farm.GoogleAdGroup GAG
join farm.GoogleCampaign GC on GAG.googlecampaign_id_fk = GC.id
where campaign_type like 'product'
limit 50;
I just need the code to keep the 'category' section and remove everything else.