且构网

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

MySQLi WHERE LIKE多个条件

更新时间:2023-09-16 23:31:52

SELECT * FROM `table` WHERE `town` REGEXP 'POOLE|WALLASEY';

这将匹配具有一个或多个POOLE或WALLASEY实例的任何行.

This will match any rows that has one or more instances of POOLE or WALLASEY.

在PHP方面,取决于数据集中有多少种分隔符(在本例中为'/'),它很快就会变得很混乱. 但是用'|'代替'/'在getPlayerTown()中似乎是一种方法.

As to the PHP side, depending on how many kinds of separators ('/' in this case) you have in your dataset, it can get rather messy rather quickly. But replace '/' with '|' in getPlayerTown() would seem to be one way of doing it.

关于性能,我不确定REGEXP与LIKE相比如何.

As to performance, I'm not sure how REGEXP is as opposed to LIKE.

https://dev.mysql.com/doc/refman/5.7/en/regexp.html