开发者

can I use contains function in mysql 4.0.27?

开发者 https://www.devze.com 2023-01-24 10:24 出处:网络
i run this sql in mysql 4.0.27: select * from table where contains(name,\"foo\"); report a syntax error, why?

i run this sql in mysql 4.0.27:

select * from table where contains(name,"foo");

report a syntax error, why?

can开发者_如何转开发 I using contains function in mysql 4.0.27?

thanks for help :)


I doesn't look like CONTAINS() is a MySQL function, but you can use the INSTR() function in MySQL 4.0 as follows:

SELECT * FROM table WHERE INSTR(name, 'foo') > 0;

You can also use the LIKE operator:

SELECT * FROM table WHERE name LIKE '%foo%';

However keep in mind that such queries would not use an index on the name field if one exists.

0

精彩评论

暂无评论...
验证码 换一张
取 消