1

I don't know how to search column in a specify text, let me give you an example: Specify text is: "GBX Shoe Changed".

I have search table like this:

ID | keyword
1  |  shoe
2  |  bag
3  |  gb
4  |  hat

I want to get records in search.keyword in my specify text "GBX Shoe Changed". The result are two records has ID 1 and 3.

Thanks.

Huy
  • 91
  • 1
  • 6

1 Answers1

2

If i understand the question correct, what you need is the inverse of LIKE %%, this can be achieved like this:

MySQL: What is a reverse version of LIKE?

SELECT keyword FROM search 
WHERE 'GBX Shoe Changed' LIKE
  CONCAT('%', keyword, '%')

Fiddle

Community
  • 1
  • 1
BobbyTables
  • 4,481
  • 1
  • 31
  • 39
  • 1
    Thanks, it's work! I found other way for this query using Instr function ` SELECT keyword FROM search WHERE INSTR(GBX Shoe Changed,`save_searches.keyword`)` http://www.w3resource.com/mysql/string-functions/mysql-instr-function.php – Huy Aug 20 '15 at 06:52
  • glad i could help - then you should mark it as the answer with the checkmark next to the voting arrows @Huy – BobbyTables Aug 20 '15 at 06:54
  • @Huy nice find with the INSTR! – AdrianBR Aug 25 '15 at 10:07
  • I'm very glad to help and find other way to to resolve an issue. – Huy Aug 27 '15 at 04:16