SQL Wildcard search issue

sql server wildcard search performance
sql contains
sql wildcard escape
symbol in sql
how to make search faster in sql server
sql check if string contains letters
sql like
mysql wildcard

This is the question in 'Hackerrank'

"Query the list of CITY(Column) names from STATION(Table) that do not start with vowels and do not end with vowels. Your result cannot contain duplicates."

Below is my answer, but I am getting an error in Hackerrank. Am I missing something that is very silly?

SELECT DISTINCT [City] FROM [Station] WHERE [City] NOT LIKE '[aeiou]%[aeiou]'

Just break it up...

[City] NOT LIKE '[aeiou]%' AND [City] NOT LIKE '%[aeiou]'

How to use wildcard characters in the SQL-SELECT statement in , LIKE operator. The LIKE operator is used in a WHERE clause to search for a specified pattern in a column. Having the wildcard (%) at the end of the string when searching on uncertain characters is not as challenging as having the wildcard at the beginning of the search string. For example, searching on a character field with 'abc%' is not an issue if the column has an index, but searching '%abc' is always slow because it does an index scan.

I would say take off start and end closing brackets aswel

[City] NOT LIKE 'aeiou%' AND [City] NOT LIKE '%aeiou'

SQL Wildcards, to perform tasks such as update data on a database, or retrieve data from a database. The reason that these rows were returned as results, is the character “_” (underscore) which is a wildcard character to match any random single character. Other special characters, that can be used with SQL Server are “%” and “ [“. When these characters are used for searching for strings, the Server treats them as wildcard characters and literal.

This works:

  distinct (city)
  city not rlike '^[aeiouAEIOU].* $'
  AND city not rlike '^.* [aeiouAEIOU]$';

Lesson 1: What is SQL?, SQL Server Wildcard Searches Using %​​ Assuming the Employee table has an index on the Name column, you will quickly see the last two queries are slower than the first one because they do an Index Scan and instead of an Index Seek. The first query is faster because the WHERE condition is Sargable. Re: SQL Wildcard Issue sqlString is quite large enough. When debugging, I can see that it fits with plenty of extra room. I don't think the problem is with the RPG, because I try all three sql strings uing strsql, and I get the same results. It yields results when I use %keyword% and keyword%, but not when I use %keyword.

Remove space from above query, this will work perfectly

  distinct (city)
  city not rlike '^[aeiouAEIOU].*$'
  AND city not rlike '^.*[aeiouAEIOU]$';

How to make SQL Server Wildcard Searches Faster, Having the wildcard at the end of the string, like 'abc%' , would help if that column were indexed, as it would be able to seek directly to the  Percent character (Wildcard - Character(s) to Match) (Transact-SQL) Matches any string of zero or more characters. This wildcard character can be used as either a prefix or a suffix. Examples. The following example returns all the first names of people in the Person table of AdventureWorks2012 that start with Dan.

SQL Wildcard Search - Efficiency?, A performance issue I see often is when users need to match part of a string with a query like the following: WHERE SomeColumn LIKE N'%  SQL Wildcard Characters. A wildcard character is used to substitute one or more characters in a string. Wildcard characters are used with the SQL LIKE operator. The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.

One way to get an index seek for a leading %wildcard in SQL Server, To broaden the selections of a structured query language (SQL-SELECT) statement, two wildcard characters, the percent sign (%) and the  There has been a debate at work recently at the most efficient way to search a MS SQL database using LIKE and wildcards. We are comparing using %abc% , %abc , and abc% . One person has said that you should always have the wildcard at the end of the term ( abc% ).

Using Wildcard Characters in the CONTAINS Predicate, asterisk (\*) as a wildcard character to represent words and phrases. the specified search word followed by zero or more other characters. This would search for issues containing the specified value so using just Pig_Duck_0 with no wildcard should work. The Summary field uses the ~ operator so if I search my JIRA for issues where summary ~ leave I get issues where summary contains the word 'Leaver'.