D
D
Dreaded2018-05-20 17:59:31
MySQL
Dreaded, 2018-05-20 17:59:31

How to do case insensitive search in MysQL?

The problem is that per type query and per DB query gives different results. I looked in the search on the toaster - already 3 years ago they asked a similar question - but they did not find a solution. table encoding, and base encoding is utf8_general_ci. update: I will add some information: If I make a request through the MySql console in this form:
SELECT * FROM table WHERE name LIKE '%Name%;
SELECT * FROM table WHERE name LIKE '%name%;
5b01e7817953e152603868.jpeg

SELECT * FROM table WHERE name LIKE '%name%' COLLATE utf8_general_ci;

That query ceases to be case sensitive. But the next problem arises. If I make this request via php script:
$query = "SELECT * FROM table WHERE name LIKE ? OR description LIKE ? COLLATE utf8_general_ci ";
  $stmt = mysqli_prepare($connection, $query);
  mysqli_stmt_bind_param($stmt, 'ss', $searchQuery, $searchQuery);
  mysqli_stmt_execute($stmt);

The following error occurs:
COLLATION 'utf8_general_ci' is not valid for CHARACTER SET 'binary'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
eldar_web, 2018-05-20
@eldar_web

Sql LIKE how to do case and character insensitive?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question