SQLite: execute case-sensitive LIKE query on a specific query

I want to run a query SELECT ... LIKEin case sensitive SQLite. But I want this one request to be case sensitive, and nothing more.

I know that there is

PRAGMA case_sensitive_like = boolean;

But this is like changing all LIKE requests.

How can I enable case-sensitive LIKE for a single request?

Examples: I want the query "FuN" to match "blah FuN blah", but not "foo fun bar".

(This works under PHP using PDO)

I could switch this and then turn it off after the request, but I can worry about the consequences that may have (efficiency, etc.). Is there any harm?

I do not have write access to the database.

(This is under Windows Server 2008)

SELECT id, summary, status FROM Tickets WHERE summary COLLATE BINARY LIKE '%OPS%';, SELECT, , .

+5
6

PRAGMA case_sensitive_like = true/false;

? - ASCII, Unicode, SQlite UC .

SQlite REGEXP, www.sqlite.org/lang_expr.html.

+7

Try:

 SELECT id, summary, status FROM Tickets WHERE summary GLOB \"*OPS*\";

* OPS .

+2

, , , php- , , .

$rs = mysql_query("Select * from tbl where myfield like '%$Value%'");


while($row == mysql_fetch_assoc($rs))
{

     if (strpos($row['myfield'],$Value) !== false)
     {
        $Matches[] = $row;
      }


 }

 print_R($Matches);
+1

- :

YOUR_COLUMN YOUR_COLUMN COLLATE latin1_general_cs LIKE '% YOUR_VALUE%'

, . . 'cs' 'ci' . .

UPDATE

. . mysql. SQLLite BINARY, .

ref: http://www.sqlite.org/datatype3.html#collation

0

, ( ). sqlite collations.

CREATE TABLE user (name VARCHAR(255) COLLATE NOCASE);

LIKE .

COLLATE , :

SELECT * FROM list WHERE name LIKE '%php%' COLLATE NOCASE

, ASCII . "A" == "a", "Æ" != "Æ"

SQLite sqlite_create_collation, PHP, PDO .

-1
SELECT * FROM table WHERe field LIKE '%search_term%'

In this form, SELECT is case insensitive.

-2
source

All Articles