mysql where子句trim不起作用

时间:2014-09-22 09:04:30

标签: mysql

+-------------+----------------+-----------------+-----------------+
| tutorial_id | tutorial_title | tutorial_author | submission_date |
+-------------+----------------+-----------------+-----------------+
|           3 | JAVA Tutorial  | Sanjay          | 2007-05-21      |
+-------------+----------------+-----------------+-----------------+

查询

SELECT * from tutorials_tbl WHERE TRIM(tutorial_title)='JAVATutorial';

没有找到记录

3 个答案:

答案 0 :(得分:3)

尝试使用REPLACE代替TRIM

SELECT * from tutorials_tbl WHERE replace(tutorial_title,' ','')='JAVATutorial'

答案 1 :(得分:2)

我认为您需要Replace而不是Trim

SELECT * from tutorials_tbl WHERE Replace(tutorial_title, ' ', '')='JAVATutorial';

DETAILS

答案 2 :(得分:1)

TRIM 仅在开头或结尾处删除不可见的字符(例如空格,制表,断行等)。如果您想要其他空间,则必须使用其他命令,例如替换

SELECT * from tutorials_tbl WHERE REPLACE(tutorial_title)='JAVATutorial';