Toni Michel Caubet
Toni Michel Caubet

Reputation: 20163

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

"pescado" -> 1 result

"sopa" -> 0 results :(

how can i fix?

Upvotes: 0

Views: 563

Answers (2)

Kel
Kel

Reputation: 7790

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.

Upvotes: 1

user463535
user463535

Reputation:

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%';

Upvotes: 2

Related Questions