i have a leads table that has a field named referrer..which has data like this
refferer
yahoo:fine dining
google:cash register
google:sale systems
google:or sale
http://www.somesite.com/
google:software
This data is the php $_SERVER['HTTP_REFERER']
but this is all in one field ...is there an easy way to split this up in two fields seperated by the : so the final result should be two fields ...Also the referrer field maybe blank as well
refferer keyword
yahoo fine dining
google cash register
google sale systems
google or sale
http://www.somesite.com/
google software
I really just need an update statement that will seperate the keyword and insert into the keyword field
i looked at mysql string functions and noticed SUBSTRING_INDEX
but not sure if that would be the best tool for this task
You can use
SELECT SUBSTRING_INDEX(referrer, ':', -1) as keyword,SUBSTRING_INDEX(referrer, ':', 1) as referrer FROM table;