Muthu Ganapathy Nathan
Muthu Ganapathy Nathan

Reputation: 3307

CONTAINS Not Working in mysql

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

Upvotes: 0

Views: 1855

Answers (3)

jcho360
jcho360

Reputation: 3759

you missed the Where condition,

try this:

SELECT * FROM MUTHU
Where MY CONTAINS ( MY,"how" );

Upvotes: 0

hillmandj
hillmandj

Reputation: 83

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;

Upvotes: 1

JodyT
JodyT

Reputation: 4412

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

SELECT * FROM MUTHU
WHERE MY LIKE '%how%';

Upvotes: 1

Related Questions