I need to parse the retweet username from a tweet string using a mySQL query.
A field would look like "RT @sampleuser: some tweet text, @useridonotwant more text"
I need to return only "sampleuser" (to populate another column with). Can this be done with mySQL?
Thanks!
Update: As requested, what I have found out so far is that mySQL does not provide a method of returning substrings via regex.
I tried using this substring solution found here:
SUBSTRING(
haystack,
LOCATE('@', haystack) + CHAR_LENGTH('@'),
LOCATE(
':',
haystack,
LOCATE('@', haystack) + CHAR_LENGTH('@')
)
- (LOCATE('@', haystack) + CHAR_LENGTH('@'))
) as string
FROM (SELECT FROM schema_name.table_name AS hastack)
But that returns a 1064: you have an error in your sql syntax.