I am trying to remove a ton of unnecessary rows in this table.
Currently there are 1.3m of them which are all an individual transaction id - with the country and destination assigned for each which is wayy wrong, given that the actual flight id is contained within the transaction id string.
The worst thing in the dataset which I've inherited, is the fact that within the transactions table there is a column with the extracted flight id as if it were a foreign key, but above is the 'flights' table. 'eyeroll'
My question is, how do I extract just the part which I have coloured in red? I can't use Left, Mid or Right, because they are variable lengths, some with 3 and 4 digits in the flight id itsself.
Is there a regex or something which can extract the text situated between 2 sets of underscores? which is just about the only viable rule in this sense.
Please bare in mind that I have never used regex before, and would need advice on how to format the expression in my query design view.
Any help is appreciated.
1_20120113_
on the front of the txn_id value? If you don't have to figure out the position of the 2nd_
, that makes this easier.