mysql: find rows which have a field that is a substring of “string”

前端 未结 4 781
猫巷女王i
猫巷女王i 2021-01-23 10:21

is there a way to write an sql query that finds all rows where the field value is a substring of a given string.

Example:

table names

Name      |      N         


        
4条回答
  •  误落风尘
    2021-01-23 11:06

    SELECT * FROM names WHERE INSTR(Nickname,Name) > 0;
    

    or, equivalently:

    SELECT * FROM names WHERE LOCATE(Name,Nickname) > 0;
    

提交回复
热议问题