Questions tagged [sql-like]

The LIKE predicate is used to search for a specific pattern in a column.

The LIKE predicate is used to search for a specified pattern in a column. The wildcard character % stands for a sequence of zero or more characters, the wildcard character _ stands for a single character.

Examples of usage:

Starts with P

SELECT * FROM Person
WHERE name LIKE 'P%'

Ends with P

WHERE name LIKE '%P'

Contains P (will match anywhere in the string so this potentially returns a lot of rows)

WHERE name LIKE '%P%'

Has an E as second character:

WHERE name LIKE '_E%'

You can also combine any other conditions using AND or OR operators.

References

3176 questions
1
vote
2 answers

MYSQL LIKE categories returning wrong query due to %

I have a CMS with a bunch of different tags and categories. I obviously use each category as a unique ID and save them in the database like so: cats -> 2,15,115 tags -> 13,33,113 That is a simple example. I am having problems when I want to show…
eberswine
  • 1,224
  • 3
  • 20
  • 39
1
vote
1 answer

search array element in LIKE mysql

i have a stored procedure that searches like bellow: BEGIN #At first, Search in name of job: (SELECT * FROM tb_job WHERE `name` LIKE '%some%' AND `name` LIKE '%thing%') UNION # second, search for tags: (SELECT * FROM tb_job WHERE id IN ( …
Fatemeh Gharri
  • 369
  • 2
  • 6
  • 20
1
vote
1 answer

SQL LIKE for numeric search

I am working with some databases input with searching the data by alpha and numeric. I am using LIKE show the alpha and everything works well except for numeric input. SELECT * FROM `product` WHERE `name` LIKE `[0-9]%` Is there any mistake in the…
1
vote
1 answer

invalid escape character "\\" was specified in a LIKE predicate

i'm getting this error message with my query.. i'm using openjpa and sql server for my database... this is my query: public static List getALLbyProductor(String productor){ Query q =…
user2018726
  • 638
  • 2
  • 12
  • 23
1
vote
1 answer

SQL Like condition

I have 2 sql tables first table called processed relatedorders (type in nvarchar) 132,112,144,155 116,113 11,44,15,16 and second table called orders and looks like orderid (type int) 132 112 155 116 I want to select orderid from orders table where…
1
vote
1 answer

How to use special characters in SQL Server LIKE clause

I have a table in which I want to get the strings which are like ab aabb aaabbb ...... a n times followed by b n times as shown below. Eg TABLE: value ---------- ab aabb aaabbb aaaabbbb 1 1a abababa I want the result TABLE…
Naresh
  • 657
  • 3
  • 16
  • 35
1
vote
0 answers

HSQLDB LIKE query fails with sharp-s

I'm unable to write a working LIKE query for a field containing the German sharp-s (ß) in a case-insensitive text field. Using HSQLDB 2.2.9, create a table with a case sensitive field and a case insensitive field. CREATE CACHED TABLE MYTABLE (MYKEY…
1
vote
2 answers

Regex url block specified word AND optimization

The simplified code: SELECT 'ok' WHERE '/articles/new/' ~ '^/articles/(?!new)([\w-]+)/$'; Examples, what I want: '/articles/new/' => '' '/articles/new-york/' => 'ok' '/articles/other-string/' => 'ok' And, what's wrong: '/articles/new/' =>…
bsz
  • 61
  • 8
1
vote
2 answers

SQLite fuzzy duplicate search using LIKE

I have a table with 4 entries. CREATE TABLE tab( name Text ); INSERT INTO "tab" VALUES('Intertek'); INSERT INTO "tab" VALUES('Pntertek'); INSERT INTO "tab" VALUES('Ontertek'); INSERT INTO "tab"…
1
vote
0 answers

Firebird search (like) on blob sub_type 1 (.NET Driver)

I am trying to search some text in a Blob sub_type 1 field. When the search text is from 1 to 28 characters, the search works fine. When the search text is over 28 characters, I am getting a "-303 arithmetic exception, numeric overflow, or string…
1
vote
1 answer

Fuzzy Duplicate Finding with SQLite

this is my first post and I'm something of a novice. I'm trying to extract a list of fuzzy duplicates from and table of company names using SQLite with sqlite3. For example, for a company like 'ZtPay' I'm currently using: SELECT name FROM tab…
1
vote
1 answer

Select from SQL database all rows that CONTAIN a certain text string in specific column

I've been looking at other posts such as this and this but nothing works for my specific case. I have a table like this: | Name | Reference | Etc... | |------------|-----------------|--------------| | John Doe | |…
QuestionerNo27
  • 610
  • 6
  • 14
  • 30
1
vote
3 answers

Like search is case sensitive?

I have a query like this, executed on a table where there are a couple keywords comma seperated in the field keywords with a leading and trailing comma: SELECT media_id, filename FROM media WHERE keywords LIKE '%,house,%' However, it won't find…
Cobra_Fast
  • 15,671
  • 8
  • 57
  • 102
1
vote
4 answers

Group by using LIKE Operator and ignore NULL value

I have written one query to group the tax items, if tax is null, i dont want to display the tax name. How to do this? Please check my sql server statement: SELECT 'CENTRAL EXCISE DUTY' AS 'TaxName', SUM(TaxAmount) AS 'Tax' …
thevan
  • 10,052
  • 53
  • 137
  • 202
1
vote
4 answers

NOT LIKE clause not working in SQL

I am trying to list all the courses for a person, where the course code doesn't start with a 'C'. The following code is still bring up 'C-...' codes. Any idea how to fix it? SELECT u.idnumber, u.firstname, u.lastname, r.id, c.idnumber AS m_name,…
pluke
  • 3,832
  • 5
  • 45
  • 68