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
1 answer

Why is my LIKE query not returning any records in Microsoft Access 2013 only?

My SQL query is as follows: SELECT * FROM Suppliers WHERE SupplierName LIKE 's%'; When I submit this query on W3 School's TryIt Editor (v1.2) (http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_like), it returns a number of records…
StockB
  • 755
  • 1
  • 13
  • 33
1
vote
1 answer

LIKE query sql not working in concatenated values with space

I have this table ** -------------------------------------------------- | id | fname | lname | age -------------------------------------------------- | 1 | John | Smith |…
woninana
  • 3,409
  • 9
  • 42
  • 66
1
vote
2 answers

Alternative Solandra for cassandra

Anyone knows an alternative to Solandra in Cassandra? I can't use "like" clause, and in my case i'll use always. Thanks.
Storm
  • 59
  • 1
  • 2
  • 12
1
vote
1 answer

sqlite with multiple like

I am trying to set up a query with php and sqlite and the query has multiple LIKE conditions... $findMe = 'blah'; $nLast = -1; $nRecord = 5; $db = new PDO('sqlite:data.db'); $qry = "SELECT * FROM mytable WHERE (id >…
jayveesea
  • 23
  • 4
1
vote
1 answer

MySQL where like with multiple words and order by weight

Let's have a simple InnoDB table questions containing one column text, which contains following data: What color does the sun have? What year it is? What year was Barack Obama born? Where in europe people speak french? When stackoverflow…
tsusanka
  • 4,801
  • 7
  • 36
  • 42
1
vote
1 answer

Likes Button from phpacademy

I have been working on the header recently. Now I'm end up to create some likes button like Facebook do. I'm following the PHPacademy on Youtube. The one who's called Alex is really awesome to share what his idea is. The problem is, I can't show the…
Obink
  • 229
  • 2
  • 13
1
vote
2 answers

t-sql LIKE and special characters

"[" is not classed a unicode character http://en.wikipedia.org/wiki/List_of_Unicode_characters (my guess) as to why this wouldn't work: declare @v nvarchar(255) set @v = '[x]825' select 1 where @v like '[x]825'
bizl
  • 1,535
  • 2
  • 12
  • 21
1
vote
2 answers

Write like and not like dynamically in plpgsql

SQL1: select regno from student where regno **like 'ABCD%'** This is running successfully. But how can I write like 'ABCD%' dynamically? For example: CREATE OR REPLACE FUNCTION check_regno(refcursor, character varying) RETURNS refcursor…
1
vote
1 answer

Show two fields from two tables as one field in mysql LIKE

I want to implement like search for autocomplete.I have two tables,Location and SubLocation. I want to return only one field for this like.Here is my query SELECT l.loc_name,sl.sub_loc FROM Location l,SubLocation sl where l.loc_name LIKE '$term%'…
user2244804
1
vote
3 answers

SQL LIKE for partial sentence value

I have a database (change) which I am trying to create an sql report on the detail field value. The issue is that the detail value displays a "phrase" and I need to evaluate based on this phrase, or a part of it. SQL SELECT * FROM change WHERE…
1
vote
2 answers

Getting MySQL syntax error using CodeIgniter LIKE active record

This is my code return $this->db ->select('organization') ->like('title',$this->db->escape_str($query)) ->or_like('description',$this->db->escape_str($query)) ->get('shop_search') …
Alireza
  • 5,444
  • 9
  • 38
  • 50
1
vote
1 answer

Convert sql Non-Unicode parameter to Unicode

I have two records in my person table in my database, their last names are "تحصیلداری" and "موقر". when I use select * from Person where Lastname like N'%ی%' the record containing "ی" character in last name returns, which is exactly what I need,…
Mahdi Tahsildari
  • 13,065
  • 14
  • 55
  • 94
1
vote
1 answer

Can MySQL fulltext search be adapted to search for partial words?

I implemented MySQL fulltext search and worked perfect. Now the client wants that partial matches be found by the search, for example the term 'base' should match 'database'. I know the whole idea of fulltext search is based on word delimiters, and…
Petruza
  • 11,744
  • 25
  • 84
  • 136
1
vote
4 answers

Space in SQLite query

WHERE g.value like '" + lookingFor + "%' I have an EditText which filters cursor from SQLite database. I want to take 'value' from 'g' table. For example one of 'value' is 'full stop'. When I input 'stop', query should find full stop. If lookingFor…
Joe Rakhimov
  • 4,713
  • 9
  • 51
  • 109
1
vote
2 answers

How to select with N like

I have a problem with my project when work with MSSQL TableName: tbA ID | COL ---+------ 1 | 'abc' 2 | 'azc' 3 | 'xyz' 4 | '123' Proceduce: pSearch(@input string) I want to select tbA combines LIKE, IN and OR with ideal: SELECT * FROM tbA a…
Kỵ Long
  • 19
  • 2