开发者

Mysql search case insensitive

I'm having problems searching in multiple tables for different values. When I search for "paul" I get nothing, but if I search for "Paul" I get the corresponding persons for orders with the name Paul.

$get_orders = mysql_query("
SELECT
  co.id, co.final_id, co.shop_id, co.customer_id, co.payment_type, co.payment_currency, co.billing_email, co.billing_first_name, co.billing_last_name, co.delivery_first_name, co.delivery_last_name, UNIX_TIMESTAMP(co.order_created) AS order_created, c.email, s.site_name, 
MATCH(co.final_id, co.billing_first_name, co.billing_last_name, co.delivery_first_name, co.delivery_last_name, co.order_created) 
AGAINST ('$match_against' IN BOOLEAN MODE) AS score 
FROM customer_orders AS co 
LEFT JOIN customers AS c ON c.id = co.customer_id 
LEFT JOIN shops AS s 开发者_运维知识库ON s.id = co.shop_id WHERE co.status = '{$os}' 
ORDER BY score DESC 
LIMIT $offset,$views_page") or die(mysql_error());

I've search all over for a solution to this problem. I've tried using UPPER, changing the database collation from utf8_general_ci to utf8_bin (binary) but my problem still remains unsolved..

All suggestions are appreciated..

Regards


from the mysql manual:

The default character set and collation are latin1 and latin1_swedish_ci, so nonbinary string comparisons are case insensitive by default. This means that if you search with col_name LIKE 'a%', you get all column values that start with A or a. To make this search case sensitive, make sure that one of the operands has a case sensitive or binary collation. For example, if you are comparing a column and a string that both have the latin1 character set, you can use the COLLATE operator to cause either operand to have the latin1_general_cs or latin1_bin collation:

see: mysql case sensitivity


See http://bugs.mysql.com/bug.php?id=22343

From my understanding, make sure everything is a string if you want to search for a string.

Also, switch charset back to case-insensitive. No need for it to be binary.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜