2 results \"pes开发者_Go百科cado\" -> 1 result" />
开发者

i get no results using LIKE in mysql when names contain CAPS characters or not

Example

Names in database:

-Sopa de pescado

-Sopa de tomate

if i search for:

"Sopa" -> 2 results

"pes开发者_Go百科cado" -> 1 result

"sopa" -> 0 results :(

how can i fix?


You can convert all your search queries to lowercase and then use a query like this

SELECT * FROM Table_Name WHERE LOWER(Column_Name) LIKE '%pescado%';


You can use LOWER() function in WHERE part of your query. See here for function details.

Also, you may use COLLATION operator. In this case query will look in the following way:

SELECT *
FROM
    table
WHERE
    col_name COLLATE latin1_general_ci LIKE '%sopa%';

See here for details.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜