简体   繁体   English

如何使用PHP在Access数据库中搜索字符串/关键字?

[英]How to search for for strings/keywords in Access database using PHP?

I'm working on a school assignment and I've an Access database which has a memo field that stores lots of text. 我正在做学校作业,并且有一个Access数据库,其中有一个存储很多文本的备注字段。 I wanna know how I can search for specific keywords in that memo field. 我想知道如何在该备忘字段中搜索特定的关键字。 For instance, from my search box I want to search for following keywords in the memo field whether they are stored in upper or lower case. 例如,从我的搜索框中,我想在备注字段中搜索以下关键字,无论它们是以大写还是小写形式存储的。 PHP, Java, SQL, Python, MySQL PHP,Java,SQL,Python,MySQL

If any one of the keywords are present in the text field, then results will show up. 如果文本字段中存在任何一个关键字,则将显示结果。

Assuming MS Access is the database and the keywords of interest are (PHP, Java, SQL, Python, MySQL) you could use the following: 假设MS Access是数据库,并且感兴趣的关键字是(PHP,Java,SQL,Python,MySQL),则可以使用以下命令:

select *
from   name_of_your_table
where  lcase(memo_field_name) like '*php*'
    or lcase(memo_field_name) like '*java*'
    or lcase(memo_field_name) like '*sql*'
    or lcase(memo_field_name) like '*python*'
    or lcase(memo_field_name) like '*mysql*'

The lcase function changes all characters in the memo field to lower case. lcase函数将备注字段中的所有字符更改为小写。 That way, when compared with your keywords in lower case, it is essentially performing a case insensitive search. 这样,当与关键字以小写字母进行比较时,它实际上是在执行不区分大小写的搜索。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM