且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 MySQL 中搜索多列?

更新时间:2023-01-29 15:56:34

您可以使用 AND 或 OR 运算符,具体取决于您希望搜索返回的内容.

You can use the AND or OR operators, depending on what you want the search to return.

SELECT title FROM pages WHERE my_col LIKE %$param1% AND another_col LIKE %$param2%;

两个子句都必须匹配才能返回记录.或者:

Both clauses have to match for a record to be returned. Alternatively:

SELECT title FROM pages WHERE my_col LIKE %$param1% OR another_col LIKE %$param2%;

如果任何一个子句匹配,那么记录将被返回.

If either clause matches then the record will be returned.

有关您可以使用 MySQL SELECT 查询执行的操作的更多信息,请尝试使用 文档.

For more about what you can do with MySQL SELECT queries, try the documentation.