I'm not sure if this is possible but I have a small MySql database that is used with a call screener app for my PBX.. I can add single numbers such as (555) 123-4567, however I would like to enter in entire blocks of numbers like (555) 123-???? so that any number calling from the numbers (555) 123-0000 through (555) 123-9999 would be selected in one entry. I know you can use wildcards in queries etc., but can they be used inside row or column fields?
I think that should work, if you reverse the parameters of like. So if you have a table with 'number masks' to match with (assuming some table and column names here), it could look like this:
select * from NumberMasks m where :CallerNumber like m.Mask
For clarity: :CallerNumber is the phone number of the caller. NumberMasks is just an assumed name for the table, where Mask would be the column containing the mask to match with in the form of (555) 123-???? as specified in the question.
Related
I have homework from Microsoft Access for school and one of the tasks was to make a search form in query, where you type for example 1. grade, 2. grade or 1st year, etc... But the field contains the name of the classes such as IT1, IT2, E1A, E3C, etc... So I could not just make a search form with [Enter Class:] or Like [Enter Class:]&"*" in the criteria column. So I was thinking, that I can use the IIF statement but it doesn't work how I imagined. I think there is a problem with the LIKE statement. I read on forums, that the IIF statement should be used in the field column but I tried the simple examples in the criteria and it worked just fine. So my question is, how I can make a search form, where I type numerous letters with one certain number in it BUT only the number will be read and returned with the same number in classes. Example: I type to search 1. grade and the value will return classes IT1, E1A, E1B, E1C, E1D. This is the line I used in the criteria column:
Like IIf([Enter the grade:]="*1*";"*1*";IIf("*2*";"*2*";IIf("*3*";"*3*";IIf("*4*";"*4*"))))
Just to qualify, I'm beginner in access and databases overall, so there is big possibility, that I'm missing something.
Thank you for help! Cheers!
Assuming input will always start with a number and you want all values containing that number, consider:
WHERE fieldname LIKE "*" & Val([Enter grade]) & "*"
Also assumes values contain only single digit.
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
I have a worksheet (worksheet1) with country codes in the A column and country names in the B column. In an other worksheet (worksheet2) is a long list with the country names and other additional informations (in the same cell). How to show the country code in the B column of worksheet2 from the list in worksheet1 if the cell contains a specified country name.
I have no idea which function(s) shall I use.
If I've understood the question correctly, you have a list of countries and codes in your first sheet like this:-
And you want to do a lookup on a list of countries with additional information in your second sheet like this:-
You could try using a formula like the one shown. It does a 'FIND' with each of the countries in sheet1!b2:b5 in turn to see if any match with sheet2!a2. Then the MATCH statement picks out any which do from the resulting array, and the INDEX statement finds the corresponding country code in sheet1!a2:a5.
=IFERROR(INDEX(Sheet1!A$2:A$5,MATCH(TRUE,ISNUMBER(FIND(Sheet1!B$2:B$5,A2)),0)),"")
Must be entered as an array formula with Ctrl-Shift-Enter and pulled down as required.
If you were prepared to switch the order of the columns in worksheet1 then VLOOKUP should serve.
Without changing the sequence the very slightly less easy INDEX/MATCH combination should serve.
There are hundreds, if not thousands, of examples of both on SO.
MATCH to look for the location in your country name column, relative to the top of your range, of the country name you choose and INDEX to take that relative location and return whatever is in there within your country code column.
If your country name is within other text in the same cell (ie a substring of a longer string) there is no option but to find some means to extract it first - there is no way to match a long string to a shorter one (though shorter to longer is possible).
The following field of a table:
AttorneyEmail(varchar(150), null)
Can have more than one email address, but has this email address in all "helpdesk#dns.org".
I have the following within the Where clause to not include in results:
and aa.AttorneyEmail NOT LIKE ('helpdesk%')
But it still does.
Any help would be appreciated.
Regards,
What you're describing doesn't make much sense. If every row contains the helpdesk address within its AttorneyEmail value (as you say) then a WHERE predicate such as you are trying to use (spelled as #AlexK demonstrates) would exclude all rows. (Also, such a DB structure is pretty ugly.)
In that case, if the point is to strip the helpdesk address from the column value in your results, then you need to do so in the selection list, something like
SELECT REPLACE(aa.AttorneyEmail, 'helpdesk#dns.org', '') AS AttorneyEmail,
...
You may need to adjust that to remove excess delimiters; I can't suggest exactly how because I don't know how you are structuring the values.
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.