It is possible to select just words that don't contain numbers?
Something like...
|Address |
-----------------
|Street x 150 |
|Street y |
|Street z 498Z |
I want just Street y in this case.
I have these texts in a excel, and would 'filter' in access. And in last try I can pass it to a SQL Server (microsoft).
I'll search about REGEX on Access or mssql.
Here is a way to do it in SQL Server (and most other databases):
select *
from t
where address not like '%[0-9]%'
That is, the address is not like something that has a number in it.
Like in Access does not follow the standard at all (using * rather than % as the wildcard, for instance). So, this will not work in Access.
SELECT ... FROM ...WHERE fieldname REGEXP [^0-9]
Related
I want to match custom pattern in one of the column in a SQL Server database. The problem is I don't know the exact pattern length.
I want only those rows which has 'function' and 'alphanumeric pattern' which has min 5 and max 8 characters. Starting and ending characters are not fixed, not case sensitive.
Column value looks like this:
Row Value
--------------------------------------------------------------------
1 I have a single own function and its namely 123BA689,BAS54256
2 Everyone has base function AFD12,CHD12234
3 Nicole has its own ASS1256902,25ADFG2
Desired output:
Row Value
--------------------------------------------------------------------
1 I have a single own function and its namely 123BA689,BAS54256a
2 Everyone has base function AFD12,CHD1223465AS
I have tried Like and regex to match pattern but failed.
Does anybody know how to fix it?
select *
from ab
where lower(ab.a) like '%function' and '%[a-z0-9]{6}%'
Thanks.
SQL Server doesn't support regular expressions. You could conceptually do what you want with:
where lower(ab.a) like '%function%' and
lower(ab.a) like '%[a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9]%' and
lower(ab.a) not like '%[a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9]%'
However, this will return any string that has "function", because that is an alphanumeric patter with 5-8 characters.
I would like to extract particular character from strings using StandardSQL.
I would like to extract the character after limit=.
For instance, from below strings I would like to extract 10, 3 and null. For everything that has null I also would like to make all null = 1.
partner=&limit=10
partner=aex&limit=3&filters%5Bpartner%5D
partner=aex&limit=&filters%5Bpartner%5D
I only know how to use substring function but the problem here is the positions of limit= are not always the same.
You can use REGEXP_EXTRACT. For example:
SELECT REGEXP_EXTRACT('partner=aex&limit=3&filters%5Bpartner%5D', 'limit=(\\d+)');
+-------+
| $col1 |
+-------+
| 3 |
+-------+
I have a table that has a substring value in the column and I want to write a query that checks if input string has the substring.
My table looks like:
| company | host |
| ------- | ---------- |
| ebay | ebay.com |
| google | google.com |
| yahoo | yahoo.com |
My input will be like www.ebay.com or https://www.ebay.com or www.qa.ebay.com or www.dev.ebay.com..
If I get any of the inputs I want to return the first record.
I tried looking at the CHARINDEX, INSTR but they are work in reverse. My scenario is I have substring to be searched in table and the actual string as input.
Any help is appreciated.
You can use like for this, but you also need string concatenation. In ANSI standard SQL, this looks like:
select t.*
from t
where #inputstring like concat('%.', t.host)
where #inputstring is the string you are inputting.
Note: You can also use the concatenation infix operation, which is typically || (standard) or +.
You can use the SQL wildcard like so:
SELECT * FROM table WHERE host LIKE '%ebay.com';
Go for this:
SELECT * FROM table WHERE host LIKE '%SearchString%'
It will pull all rows containing the SearchString.
You can achieve this using like operator.
Select * from yourtable
where ? like concat('%', company, '%');
parameter ? with your input.
Is there any way (a function, a config option, etc.) to force informix to ignore accents on searches?
Example:
select id, name from user where name like 'conceição%'
Returns:
1 | conceicao oliveira
2 | conceiçao santos
3 | conceicão andrade
4 | conceição barros
Thanks
Not directly, that I'm aware of. You could install the Regex DataBlade module. The use it's regexp_match function. Replacing the query with something like this:
where regexp_match(name , 'concei[çc][ãa][o]%')
Or, if you don't have that option, what I would do would be add another 'normalized_name' column. replacing all the accented characters with a "standard" character. Then query my table based on that.
name='conceiçao santos', normalized_name='conceicao santos'
Adding a normalized column will also make sure you're not dependant on any module, or any particular database for that matter.
How to match numbers in SQL Server 'LIKE'.
SpaceName
------------
| New_Space_1
| .
| .
| New_Space_8
| New_Space_9
| New_Space_10
| New_Space_11
| New_Space_SomeString
| New_Space_SomeString1
Above is my table contents.
I want to get only records ending with Numeric chars, ie I want the records from New_Space_1 to New_Space_11.
Don't want New_Space_SomeString and New_Space_SomeString1
I have some query like this.
SELECT SpaceName FROM SpaceTable
WHERE SpaceName LIKE 'New_Space_%'
But this returns all records.
what about
SELECT SpaceName FROM SpaceTable
WHERE SpaceName LIKE 'New[_]Space[_][0-9]%'
The reason I put underscore in brackets is because in a regular expression _ means Any single character. Read up on like here http://msdn.microsoft.com/en-us/library/ms179859.aspx
This solution from #SteveKass works perfect.
SELECT SpaceName FROM SpaceTable WHERE SpaceName LIKE 'New[_]Space[_]%' AND SpaceName NOT LIKE 'New[_]Space[_]%[^0-9]%'