0

I am working with CONTAINS, but it is not woking in mysql.

 mysql> SELECT * FROM MUTHU;
+---------------------+
| MY                  |
+---------------------+
| how is your studies |
| how are you there   |
| hi there            |
+---------------------+
3 rows in set (0.00 sec)
mysql> SELECT * FROM MUTHU CONTAINS ( MY, "how" );
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '( MY,
 "how" )' at line 1
Muthu Ganapathy Nathan
  • 3,199
  • 16
  • 47
  • 77
  • Is `CONTAINS` even a real MySQL function, I couldn't find anything about it on their documentation. :S – Seer Mar 15 '13 at 15:30

3 Answers3

1

I don't think MYSQL has a function called CONTAINS, try the following query:

SELECT * FROM MUTHU
WHERE MY LIKE '%how%';
JodyT
  • 4,324
  • 2
  • 19
  • 31
1

I believe contains is used primarily in Xpath/Xquery. A similar function in mysql is INSTR(). The proper code is for using this is:

    select * from MUTHU
    where INSTR(MY, 'how') > 0;
hillmandj
  • 83
  • 2
  • 11
  • @EAGER_STUDENT in response to your question below, the answer is you'll have to call INSTR twice. like so: where (INSTR(MY, 'how') > 0) or (INSTR(MY, 'hello') > 0 ); – hillmandj Mar 15 '13 at 18:20
0

you missed the Where condition,

try this:

SELECT * FROM MUTHU
Where MY CONTAINS ( MY,"how" );
jcho360
  • 3,724
  • 1
  • 15
  • 24