Find the word Capital or a small letter

I have two values ​​in the database, for example

  • This is Name
  • this is a name

I am looking for a phrase thby SQL query

SELECT * FROM [TABLE_NAME] WHERE title LIKE '%th%'

then both files show where I want to show only a part this is a name. How should I continue. I tried preg_merge and other parts, but they did not work. Is there a SQL Query that can distinguish capital and small letter. Or any php method with which I can search for the exact term. My table format is UTF8. Not a Latin general.

+4
source share
4 answers

it will work for you, try this query

SELECT * FROM table_name WHERE BINARY title LIKE '%th%'
+4
source
SELECT * FROM tableName WHERE title COLLATE latin1_general_cs LIKE '%th%'

Link

- latin1 latin1_swedish_ci, . , col_name LIKE 'a%' , A a. , , . , , latin1, COLLATE, latin1_general_cs latin1_bin:

, , . . 13.1.10, " CREATE TABLE".

+4

, .

, LOWER(), LOWER().

If you want to make sure that all of the following characters are lowercase, you can use LOWER (SUBSTRING (word FROM 2))

SELECT title
FROM [TABLE_NAME] 
WHERE (SUBSTRING(title, 1, 1) COLLATE latin1_bin) = LOWER(SUBSTRING(title, 1, 1)) 
AND (SUBSTRING(title, 2, 1) COLLATE latin1_bin ) = LOWER(SUBSTRING(title, 2, 1))
+2
source

$ keywords = '%'. strtolower ($ _ GET ['q']). '%';

$ sql = mysql_query ("SELECT * FROM items WHERE LOWER (item_code) LIKE '$ keywords'");

+1
source

Source: https://habr.com/ru/post/1529143/


All Articles