i need to query my database and find results :
我需要查询我的数据库并找到结果:
mysql_query("select * from ".ALU_TABLE." where username like '%$q%' or name like '%$q%'");
if i have a name in my table such as Book and i enter book in search box it wont show the Book
如果我在我的桌子上有一个名字,如书,我在搜索框中输入书,它就不会显示书
i need to query my database as not to be case sensitive.
我需要查询我的数据库不区分大小写。
2 个解决方案
#1
4
You can use the LOWER()
function
您可以使用LOWER()函数
... WHERE LOWER(username) LIKE blabl OR LOWER(name) LIKE asdasd
#2
3
You need to append something like COLLATE utf8_general_ci
to your query. (The _ci
suffix stands for case insensitive.)
您需要在查询中添加类似COLLATE utf8_general_ci的内容。 (_ci后缀代表不区分大小写。)
Have a look at the documentation: 9.1.7.1. Using COLLATE in SQL Statements:
看一下文档:9.1.7.1。在SQL语句中使用COLLATE:
With the COLLATE clause, you can override whatever the default collation is for a comparison. COLLATE may be used in various parts of SQL statements.
使用COLLATE子句,您可以覆盖默认排序规则以进行比较。 COLLATE可用于SQL语句的各个部分。
#1
4
You can use the LOWER()
function
您可以使用LOWER()函数
... WHERE LOWER(username) LIKE blabl OR LOWER(name) LIKE asdasd
#2
3
You need to append something like COLLATE utf8_general_ci
to your query. (The _ci
suffix stands for case insensitive.)
您需要在查询中添加类似COLLATE utf8_general_ci的内容。 (_ci后缀代表不区分大小写。)
Have a look at the documentation: 9.1.7.1. Using COLLATE in SQL Statements:
看一下文档:9.1.7.1。在SQL语句中使用COLLATE:
With the COLLATE clause, you can override whatever the default collation is for a comparison. COLLATE may be used in various parts of SQL statements.
使用COLLATE子句,您可以覆盖默认排序规则以进行比较。 COLLATE可用于SQL语句的各个部分。