Questions tagged [string-searching]

For questions about searching a string for matches

Filter by
Sorted by
Tagged with
1 vote
1 answer
5k views

Can a Postgres LIKE statement return an exact match?

I'm trying to search a Postgres table using LIKE and %, but the query is not returning results. The column local_username will contains values formatted like: username@domain.local OR username@domain....
  • 113
1 vote
1 answer
3k views

Use LIKE in column with arabic [closed]

I have a SQL Server 2012 DB with a column that includes Arabic text. The column is nvarchar(MAX) with collation Arabic_CI_AI_KS_WS. To test if LIKE searches are working I copied some of the text ...
0 votes
1 answer
49 views

TSQL - Finding Similar Values

I have a static table containing filenames (StaticFilesTbl). Each day a file is sent in that is stored in DailyFilesTbl. The filenames in DailyFilesTbl will be different from StaticFilesTbl in that ...
  • 523
2 votes
1 answer
3k views

Search entire database(210 tables) for a unique Id (PK) and get the table name

Rewritten Question: I need to look through an entire database, 210 tables for a unique ID that is a number. I have limited access to my database through things called nodes (Visual programming.) ...
  • 23
2 votes
1 answer
2k views

How do I find a job that sends a specific email?

I had a job sending an irrelevant email to a group of users. The title of the email was Staging -> [AUPAIR] arrivalDate trigger issue. When I query the jobs table in the msdb database using the ...
1 vote
1 answer
295 views

How to search for compound words, and get the word parts returned

I need to be able to search for compound words like "menneskerettighedsforkæmperens" (the human rights activist's) and find the words "menneske" (human), "rettighed" (right) and "forkæmper" (activist)....
9 votes
5 answers
6k views

Matching a ] (closing square bracket) with PATINDEX using the "[ ]" wildcard

I am writing a custom JSON parser in T-SQL†. For the purpose of my parser, I am using the PATINDEX function that calculates the position of a token from a list of tokens. The tokens in my case are all ...
  • 22.4k
13 votes
4 answers
63k views

Find if any of the rows partially match a string

I want to see if a table contains any sub-string of a given string. Let's say I have a string somedomain.com In database I have: blabladomain.com testdomain.com domain.com I need to make a ...
  • 263
0 votes
1 answer
2k views

why my split string functions are not working with large OBJECT_DEFINITION?

I have in one of my databases a stored procedure called PROCEDURE [repl].[usp_upd_repl_out_application], that is not exactly a very clever stored procedure but it has over 389 lines. As I need to ...
5 votes
4 answers
22k views

ERROR: operator does not exist: text[] ~~ text

We have an easy syntax that allows us to look into an array for a single scalar, SELECT 'foo' = ANY(ARRAY['foo', 'bar', 'baz']); We can use the same method to match with LIKE SELECT 'foobar' LIKE ...
  • 59.6k
1 vote
1 answer
3k views

Using LIKE to search case insensitive over language specific characters (PostgreSQL)

Using a PostgreSQL database (Collation C, Encoding UTF8) we store data from various languages. This means we also get the special characters for free (e.g. Å, å, ...) Within an application we now ...
  • 13
2 votes
2 answers
3k views

Return results that contain or do not contain punctuation

Is there a way within MySQL to return results using a LIKE statement that contain or do not contain punctuation characters such as apostrophes and hyphens? For example if I have one of the following ...
1 vote
1 answer
619 views

Count number of occurrences of a phrase in ntext

I am trying to create a function for counting the number of occurrences of a phrase in a ntext value. This my function's code: alter FUNCTION [dbo].[PhraseCounter] ( @pInput NTEXT, @pSearchPhrase ...
2 votes
1 answer
2k views

Search on concatenate columns

I have this : CREATE TABLE users ( first_name varchar(60) NOT NULL, last_name varchar(60) NOT NULL ); INSERT INTO users (first_name, last_name) VALUES ('Sylvia ', 'Hoeks'), ('...
  • 587
3 votes
1 answer
202 views

patindex parser

I am trying to parse a string column matching it against several patterns. I have code that does not produce the desired results. This is a sample table: -- demo data IF OBJECT_ID('dbo.Input', 'U') ...
20 votes
3 answers
3k views

What is it called when you search the middle of a string instead of the beginning?

I am trying to polish up my vocabulary to better communicate with my fellow developers. We have several places in the site where we are debating if we should search for a string from the beginning '...
0 votes
1 answer
952 views

Querying an array of strings with a string that represents search terms

I have an array of values like: array ('hello world', 'foo', 'bar') -- terms here have only letters and one space at most and some text like: 'foo hello-world hello1world' and I would like to get ...
  • 1,153
2 votes
0 answers
44 views

How to implement a "Command T" (VIM) -like search

I am thinking of implementing a string search similar to the command-t search in VIM. The context is almost the same: Finding Files in a Webapp. It's not easy to explain how the command-t search ...
  • 21
0 votes
1 answer
71 views

How to fetch records from table which has csv

Please guide me about following case. I need to fetch records from a table which has a column like shown in the picture. I need to fetch records which has 065 and AMT campaigns only. I tried: SELECT ...
3 votes
1 answer
2k views

Using SELECT within to_tsvector call in CREATE INDEX

I'm attempting to create a GIN index for full-text search on a field that may have text in it that is one of several different languages. The languages are pre-set and we'll know which language we ...
  • 471
3 votes
3 answers
3k views

Autocomplete too slow: possible optimizations?

The autocomplete search functionality of my website searches a varchar field which contains the model number of sale items. This field can contains strings varying from 1 to 75 characters and the ...
  • 1,324
2 votes
1 answer
202 views

Good databases for unanchored LIKE condition

Basically I need a database that is good with queries like LIKE %abc%. I already tried PostgreSQL with GIN indexes and it is very good, but maybe there is something even better? I also tried MongoDB ...
  • 131
0 votes
1 answer
124 views

Match similar special character in filters

I have to perform a search on a table with Turkish city names. The users would enter the first 4 characters of a city and I need to fetch the results from SQL. For example, user wants to find the ...
  • 113
2 votes
3 answers
3k views

Using fulltext search to find a sequence of digits

We have a column of ten digit numbers (with leading zeros). We are trying to find rows that have a specific sequence of digits. For example, all rows containing "5088" in any place in the column. ...
1 vote
1 answer
2k views

Compare strings from two tables SQL Server 2014

I'm using these two tables in a SQL Server 2014 database: CREATE TABLE #FORMULAS ( [ID] [int] IDENTITY(1,1) NOT NULL, [DataSourceAddress] [nvarchar](255) NULL, [Description] [nvarchar](...
  • 113
4 votes
2 answers
88 views

Performing search on a column by query

Up until today I've used LIKE %term% to query for rows on particular column term. Then I've read about FULL TEXT index. And I think I misunderstood how full text index works. I have an API that ...
8 votes
1 answer
23k views

LEFT vs CHARINDEX for matching the start of a string in T-SQL

I want to match the beginning of a string in a WHERE clause. While I recognise that so often database-performance is dependant on the underlying data structure, is there a best-practice for doing this?...
13 votes
7 answers
61k views

How to find all positions of a string within another string

How can I find all the positions with patindex in a table or variable? declare @name nvarchar(max) set @name ='ali reza dar yek shabe barani ba yek ' + 'dokhtare khoshkel be disco raft va ali ...
  • 1,032
138 votes
8 answers
218k views

Pattern matching with LIKE, SIMILAR TO or regular expressions in PostgreSQL

I had to write a simple query where I go looking for people's name that start with a B or a D : SELECT s.name FROM spelers s WHERE s.name LIKE 'B%' OR s.name LIKE 'D%' ORDER BY 1 I was wondering ...
4 votes
1 answer
2k views

Alternatives to LIKE and FTS for mid name search

I have a question about what are the alternatives for LIKE '%%' and Full-Text Search when it comes to searching organisation names, firstnames, surnames, etc. The LIKE '%%' causes table scan, however ...
  • 41

1
2