简体   繁体   English

phpmyadmin如何实现“搜索”功能?

[英]How does phpmyadmin implement “search” feature?

In phpMyAdmin , there is a search in database feature by which I can input a word and find it in any table(s). phpMyAdmin ,有一个search in database功能,通过它我可以输入一个单词并在任何表格中找到它。

How to implement it by SQL statement? 如何通过SQL语句实现它? I know the LIKE operation, but it's syntax is: 我知道LIKE操作,但它的语法是:

WHERE column_name LIKE pattern

How to search in all columns? 如何搜索所有列? Any how to specify it's a exact keyword or regular express? 任何如何指定它是一个确切的关​​键字或常规快递?

SELECT * FROM your_table_name WHERE your_column_name LIKE 'search_box_text';

Where search_box_text is what you enter in the search. search_box_text是您在搜索中输入的内容。 It will also say in the result page what kind of query it made. 它还会在结果页面中说出它所做的查询类型。 The same query with regular expressions is: 与正则表达式相同的查询是:

SELECT * FROM your_table_name WHERE your_column_name REGEXP 'search_box_text';

Remember that the wildcard in mysql is %. 请记住,mysql中的通配符是%。 Eg. 例如。 "LIKE '%partial_search_text%' “LIKE'%partial_search_text%'

If you want to search in multiple columns, you can check which columns are in table with: 如果要搜索多个列,可以检查表中的列:

DESCRIBE TABLE your_table_name;

Or if you already know your columns: 或者,如果您已经知道列:

SELECT * FROM your_table_name 
WHERE your_column_1 LIKE '%search%' 
AND your_column_2 LIKE '%search%'
AND your_column_3 LIKE '%search%';

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

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