MYSQL: 查询数据库字符串是否被包含在另一个字符串中 Search where column value is within a string

CREATE TABLE myTable(
  id INT NOT NULL AUTO_INCREMENT PRIMARy KEY,
  name VARCHAR(100),
  city VARCHAR(100));
  
INSERT INTO myTable (name, city) VALUES ('test', 'anza');
INSERT INTO myTable (name, city) VALUES ('fish', 'riverside');

 

SELECT *
FROM myTable
WHERE 'anza city' LIKE CONCAT('%', city, '%') OR 'riverside county' LIKE CONCAT('%', city, '%');

MARK !

原处:http://stackoverflow.com/a/29974002/4484798

Loading

Add a Comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.