I have members emailing in for support instead of using the online support form and they are nice enough to put their Member ID into the Subject line. I would like to extract these Member ID from the Subject line to populate the Member ID field for the support ticket.
At the moment, I am able to use something like below to find the tickets where the Subject line has the string pattern which I am looking for (7 numbers in a row). My difficulty now is how to extract these numbers from the Subject line.
SELECT t.ID, `Subject`
FROM tickets AS t
WHERE `Subject` REGEXP '[1-6][0-9][0-9][0-9][0-9][0-9][0-9]';
I have attempted to use the Strip Non Digit function from here, however, the Subject line may contain other numbers that are not part of the Member ID. How can I extract just the number block that matches that regex?
Related
data output
I am pretty new to Webi and am having an issue creating a variable. I'm trying to check if there is more than 1 email address for each entity legacy account number and if 1 of the contact names contains "Annual Report". So when I flag each entity legacy account number for no email only the ones without a contact name that contains "Annual Report" will be pulled. In the example above only the yellow groups should be called no email. Right now all of them are being pulled into no email. I have tried using if and match as those are what I am most familiar with. Does anyone have any suggestions?
There are number of ways you could do this. I am going to give an example using two variables, but you could easily combine them into one.
Has No Email Var=If(Match(Upper([Contact EmailAddress]); "NOEMAIL*"); 1; 0)
Annual Report Contact Name Var=If(Match(Upper([Contact Name]); "ANNUAL REPORT*"); 1; 0)
Then you would apply a report filter with two components...
Has No Email Var = 1
AND
Annual Report Contact Name Var = 0
Let me explain a few things...
The purpose of the Upper function is the Match function is case sensitive. If you know your email address are always lower case then you could remove that the Upper function and have it match on "noemail*".
It is significant that I only have a asterisk ("*") at the end of the string being sought. That will only find a match where the corresponding column value starts with that string. If you want it to be true whenever the string is found anywhere in the column being searched you would be asterisks on both ends.
You could also put limiting criteria in your query filter. But here is where thing can get confusing. Within the query filter you can choose the Matches pattern operator. However, the wildcard character is different ("%" rather than "*") and you do not put double-quotes around your search text. So you would have some thing like this...
Contact EmailAddress Matches pattern noemail%
AND
Contact Name Different from pattern Annual Report%
I am sure you noticed I didn't convert the search text to uppercase. In the Query Panel Web Intelligence is case-insensitive and would likely follow the case-sensitivity of the database of the source data. All of our databases are case-insensitive so if yours is case-sensitive you may need to play around this this a bit. Or just go with the approach of creating the variables and report filters as I initially laid out.
If you want a wildcard for a single character rather than multiple characters (which is what "*" and "%" will do) you need to use a "?" within your variable definition or a "_" in your query filter.
Hope this helps,
Noel
So I’m trying to set where the user adds one line of text containing the Name(Last, First Middle) as well as id number, ssn, and birthday. Example: Doe, John Hank 12345678901 123-45-6789 Jan. 01, 1801
I first split it by using “ “ to break it up into the array. I then need to find which array value has the ssn in it. Because the name can change from Sr, Jr, no middle name, etc. the array value can’t be static at like ssn = eachpart(3). Is there a way to search each piece of the array with the criteria for a mask of a ssn?
You could create and array using Split:
Parts = Split(Input, " ")
Then loop this checking for
IsNumeric(Parts(i))
That found will be the ID.
The next will be the SSN.
I run a gym and am trying to query my database to find out how many customers who signed up to the intro class also signed up to the next level class. For starters I am issuing a simple SQL command as follows:
Select * from 'classes' where 'name' = '4 Week Intro Class'
This comes back with zero matches because I assume there is no match due to the name of the class also contains dates and times. I want to only match on the partial class name not the whole name. I've tried = and LIKE and MATCH to no avail.
Once I get this result then I want to expand it further to show me all the customers who took this class also took the next level class name. Baby steps.
I can provide more info if needed. I'm using MySQL btw.
Thanks.
Ed
For your first query, there are no matches because you are comparing two strings, and they are not equal. Presumably, you intend:
Select *
from classes
where name = '4 Week Intro Class';
Only use single quotes for string and date constants.
You can use like by doing:
Select *
from classes
where name like '%Intro%';
When you ask another question, include sample data and desired results, as well as your attempt to answer the question.
I have a table that has a column named 'bio', which is a string of max length 255. Inside this bio I want to search if there's an email contained in it. I want to count how many entries in the table that has an email in the bio column. Is such thing possible to be done via SQL?
To add more clarification, bio is a free form text and I am looking to match the email pattern, and not a specific email.
You can use a query like this:
select count(*)
from mytable
where bio REGEXP '<emailregexp>'
Replace <emailregexp> with the regular expression you're using to match email patterns. There are dozens of answers for that on SO, e.g.
Using a regular expression to validate an email address
However, most of these questions are about validating an email, which assumes that the entire input field is supposed to be a single email. Make sure you remove the ^ and $ anchors for the ends of the input so that yo look for an email anywhere in the field.
I have a table where one column, named Description, has a variety of information all crammed together. Part of that information is an abbreviation for a vehicle maker. For example, the Description column could read "6cylM.Benz32zy,.026L"
I want to populate a new Vehicle column with Mercedes Benz wherever the Description column contains M.Benz somewhere inside. The key word there is "somewhere"; the abbreviated vehicle name could be anywhere in the description field.
So far I have the following code. However, MySQL tells me it can't find the %M.Benz% column. I'm not trying to look for a column named %M.Benz%, I'm trying to find TEXT that is %M.Benz%.
UPDATE tbl_arcore_repuestos
SET Vehicle = `Mercedes Benz`
WHERE Description LIKE `%M.Benz%`;
Any ideas? Most of the other solutions on StackOverflow to similar questions rely on the sought-after text being in a fixed position (like at the beginning of the string or separated by a consistent character). The text I'm looking for could be ANYWHERE in the Description column.
Have you missed the quotes or used backticks instead of quotes?
UPDATE tbl_arcore_repuestos SET Vehicle = 'Mercedes Benz' WHERE Description LIKE '%M.Benz%';