Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

The tag has no usage guidance.

0
votes
1answer
27 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....
0
votes
1answer
38 views

SSRS - select where parameter and fixed value

So there is a lot of stuff about using SSRS parameters to select multiple values but nothing about using both a parameter and a fixed value using the in select statement. So what I'm trying to do is ...
3
votes
3answers
2k views

How to do a case-insensitive LIKE in a case-sensitive database?

My vendor requires the data warehouse database to be case sensitive, but I need to do case-insensitive queries against it. In a case-sensitive database, how would you write this to be case-...
-2
votes
4answers
144 views

What is the implicit ordering of a LIKE condition?

I would like to know how the LIKE operator is classified, I have a query where I have a number of chained LIKE statements. How are the results from the following prioritized when they're returned? ...
1
vote
1answer
20 views

Join tables based on variable value contained in column

I have two tables with dates as the primary column to join. But, I also need to join based on the value from one column that is partially contained in a column from the other table. Table 1: date, ...
1
vote
2answers
519 views

Slow query performance when searching for a particular value, but fast with a different value on the same column

I have a SQL Server 2017 select statement that is executed by the front end application. The query has three joins and UNION. Each join statement has a clause where NAME LIKE '%ibm%'. When I change %...
0
votes
1answer
31 views

Just 4 Table Join query takes too much time and some time fail to execute

I am working on getting candidate detail from mysql database and for that i have created one query. Is my query structure is wrong? Here is the query: SELECT `candidate`.`id`, `candidate`.`email`,...
1
vote
1answer
275 views

Postgres collate example in select?

I would like to comprehend the different behavior of like and =. Sadly, I can not reproduce the following simple example thus that both queries return a different result: SELECT 'ä' LIKE 'ae' COLLATE ...
2
votes
4answers
1k 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 ...
1
vote
1answer
721 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 ...
0
votes
2answers
577 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
2answers
76 views

SQL regex PostgreSQL

Let's consider a table like that: id | name 1 | This is a test sentence 2 | is a sentence TeST 3 | This a IS test sentence 4 | iS a tEst sentence tHis 5 | This a test sentence is How ...
0
votes
1answer
46 views

Search for the root words using root words with prefixes or suffixes

Is it possible to search the word "FILL" saved in the SQLite database using the words "REFILL" or "FILLED"? Not just these words specifically but you get the idea of searching the root word using the ...
0
votes
3answers
275 views

Postgressql text search: pg_trgm index with order by going very slowly

I have a really slow query(~30 seconds) on a large text search DB that I could really use some help with. I'm searching for ordered text, in a long file path string. So the path could be: folder1/cat ...
13
votes
3answers
573 views

Overcome LIKE character length limitation

By reading this LIKE character length limitation here, it looks like I can't send a text longer than ~4000 characters in a LIKE clause. I'm trying to fetch the query plan from query plan cache for a ...
19
votes
1answer
3k views

Why does searching for LIKE N'%�%' match any Unicode character and = N'�' match many?

DECLARE @T TABLE( Col NCHAR(1)); INSERT INTO @T VALUES (N'A'), (N'B'), (N'C'), (N'Ƕ'), (N'Ƿ'), (N'Ǹ'); SELECT * FROM @T WHERE ...
2
votes
2answers
99 views

JOIN on LIKE when input udtt count is > 1

This query accepts a User-Defined Table Type variable and then joins that with a table. If the input is a single record, I want the join to be LIKE '%'+input+'%', otherwise it should be =input. This ...
7
votes
4answers
28k views

Select multiple values in LIKE Operator

I have a SQL query given below, I want to select multiple value using like operator. Is my Query correct? SELECT top 1 employee_id, employee_ident, utc_dt, rx_dt FROM employee INNER JOIN ...
0
votes
1answer
259 views

Postgres won't use btree index in left-anchored LIKE query [duplicate]

Using Postgres 9.5. The Postgres documentation says that the btree index can be used for left-anchored "like" queries (i.e. "%" only at end). But my left-anchored "like" queries on a 1 billion row ...
1
vote
1answer
332 views

Table indexes for autocomplete in MySQL

I need to implement an "autocomplete-like" query in MySQL, one on a fairly short textual field varchar(11) and one on a potentially long field varchar(140). As they are autocomplete query, they will ...
-2
votes
2answers
135 views

How to improve a simple LIKE on large tables

I have a business facing web application that runs on MySQL that runs a query like this on certain pages. SELECT event_user, event_type, event_details FROM `event_history` WHERE `event_details` ...
0
votes
1answer
977 views

SQL server Like pattern match with CONCAT() always fails

I am facing problem in a simple query script for SQL server. Please help The script is CREATE PROCEDURE [dbo].[Search_By_Author_And_Name] ( @Author_name AS [varchar](50) ) AS BEGIN Select B....
4
votes
1answer
1k views

Repeating pattern X amount of times in LIKE

I took a look at the documentation for patterns from Microsoft (can be found here), and from what I understood, it doesn't say a way for a pattern to repeat a limited number of times. It's either the ...
7
votes
3answers
1k views

Matching left and right single-quotes used as apostophes

I have four columns containing names and want to search these using a LIKE in a Microsoft SQL Server environment. The complication comes that names may include left and right single-quotes / angled ...
5
votes
1answer
237 views

StartsWith query using LIKE is returning the wrong results on a non ascii column

I want to query a table for entries that begin with a specific fragment of text. I am under the impression that the LIKE operator is a way to do this, so if I wanted to find all rows that have a ...
0
votes
2answers
77 views

Using LIKE with apostrophes

I have been running a server side trace in order to find out how a specific stored procedure is called within my database. I am running the following query in order to get data from the trace file ...
1
vote
4answers
688 views

Update data of one table from another with comparing columns have same initial strings

I have two tables: NewData: EName Job Sal smith clerk 2000 allen sales 2000 jones.domain.com Manager 6000 OldData: EMPNO ...
1
vote
1answer
48 views

Limiting the input to a field as some pattern

i have a table student having field admission no. i want to restrict its input to the pattern '-/----/--'. If the input does not match this format then it should show an error. I tried doing this ...
0
votes
1answer
361 views

MySQL - Like with index

I found many question, But no solutions. An index can not be used to speed up queries where the search criteria starts with a wildcard: LIKE '%text%' An index can (and might be, depending on ...
6
votes
2answers
1k views

MySQL group by like statement?

I need to get some stats out of our MySQL-DB and wonder if there is a faster way in doing this. Basically I need info about user registration for any given month before including seperation by ...
5
votes
2answers
417 views

Integrate MySql Full Text searches in CMS

I'm developing my own CMS and using MySql v5.5 DB to save the content items records. Due to a technical limitations, I can't upgrade my database to a newer version that support Full-Text searches on ...
6
votes
3answers
2k views

Like predicate to match a whole word only

I have a SQLite database with a table named minecraft. +----+----------------------+ | id | name | +----+----------------------+ | 1 | Pocket Mine MP | | 2 | Open Computers ...
3
votes
1answer
618 views

MySQL does not use index for wildcard-free query on an INT field - why?

So I have a table with two indexes, one on a VARCHAR field (url) and one on an INT field (id). If I do a query on either of those fields using a WHERE condition with the usual =, the index is used in ...
1
vote
0answers
126 views

Matching same unknown characters in two columns

So here is the situation. I have a database with values in columns that look something like this field_0_data1, field_0_data2, field_1_data1, field_1_data2 Is it possible to only select the columns ...
3
votes
2answers
2k views

Postgresql: Pattern match against array elements?

Is there any way to do a pattern match against the elements of an array in postgresql (9.4 if the version makes a difference)? I have an aggregate function that, among other things, returns an array ...
1
vote
1answer
302 views

What's the most efficient way to perform a case insensitive search for a word in a text field?

What is the most efficient way to perform a case insensitive search for a word in a TEXT (or CLOB) field? I've been using WHERE LOWER(body) LIKE '%word%' but I think the calls to LOWER() might be ...
0
votes
2answers
79 views

select where column with a %

How can I select all records with a % in? I think this code doesn't work. SELECT column1, column2 FROM table WHERE column1 LIKE '%%%' first and last % for zero, one or more chars second % for the ...
3
votes
1answer
462 views

Which is better MySQL search strategy, varchar x 2 or text column?

I have a MySQL database for an SMS application. For the sms_msg column, I initially setup varchar(255) expecting SMS to be short anyway. Now I realize that's not enough and some messages are getting ...
0
votes
3answers
321 views

If in mysql I have string `xxx yyy` - how can I SELECT this if user input `xxxyyy`?

My online-shop in PHP (OpenCart). On site we have product-search. For example product have name iSport 220, and if user search input string is iSport220 we must show this product. And vice versa. ...
2
votes
1answer
2k views

Join more than 3 tables in one single query, with many comparisons and no IDs

I use an overlycomplex and poorly designed software at my work, and now I need to produce a report of invoices issued between a period of time. Invoices are held at table ENTR2012, which uses the ...
1
vote
1answer
2k views

Using a subquery in a LIKE statement

I need to write a subquery inside a LIKE statement. This subquery would return me a word that I need to find in the middle of a sentence (that belongs to another field). Is it possible? This is how I'...
2
votes
3answers
4k views

mysql - order by first condition in where clause

I have a table consists of the following fields id, name with the following values 1, ciro 2, test ciro 3, ciprox 4, other 5, other i would like to get all the values that begin with "ci" or ...
1
vote
1answer
2k views

Query to match exact column or partial data of the column: SQL Server / Azure

Bit confused on how to get it work better than what has been done now. I am new, apologies if I'm asking for too much. I have trip details which have from and to locations stored in database from ...
4
votes
4answers
843 views

Should I normalize my string arrays, or just keep it a simple string?

I am working on a project involving cards from the Magic: The Gathering game. To be of any use, I must load the basic information about each card into my database, but some of the fields may contain ...
3
votes
2answers
78 views

Is it a better idea (performance is key) to store in a normalized table and retrieve by JOIN or in a single nvarchar column and retrieve using LIKE?

NOTE: The application is not really about websites or keywords, I am using that here only to provide reference points for discussion. I have a data set that is really just a string of words. Think of ...
0
votes
1answer
3k views

Netezza LIKE operator not finding subsequent backslashes

Netezza is able to find records when using the LIKE operator when the first character contains a backslash character. But when subsequent characters contain a backslash character, it cannot. How can ...