gpt4 book ai didi

Mysql 搜索不区分大小写

转载 作者:行者123 更新时间:2023-11-29 09:10:40 25 4
gpt4 key购买 nike

我在多个表中搜索不同值时遇到问题。当我搜索“paul”时,我什么也没得到,但如果我搜索“Paul”,我会得到名为 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());

我已经到处寻找这个问题的解决方案。我尝试使用 UPPER,将数据库排序规则从 utf8_general_ci 更改为 utf8_bin (二进制),但我的问题仍然没有解决。

感谢所有建议..

问候

最佳答案

来自mysql手册:

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:

参见:mysql case sensitivity

关于Mysql 搜索不区分大小写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5670156/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com