MySQL - Trim in Where clause

Can you use the trim function in the where clause? For example:

SELECT * from resv where trim(street) = 'Maple'.

The table may have like ' Maple' or 'Maple '.

Or maybe just

SELECT * frpm resv where street like '%Maple%'

Would that work?

The problem I see with that is I don't want a match of 'Maple Street'
Richard KortsAsked:
Who is Participating?
Dave BaldwinConnect With a Mentor Fixer of ProblemsCommented:
From :

In the WHERE expression, you can use any of the functions and operators that MySQL supports, except for aggregate (summary) functions. See Section 8.5, “Expression Syntax”, and Chapter 11, Functions and Operators.

You would have to look up the details of what that means because I'm not certain you can do exactly what you have posted.  The easiest thing is to try it and see it works or causes an error.
Richard KortsAuthor Commented:
I went ahead & tried it (in a php script),

It runs without error.

Dave BaldwinFixer of ProblemsCommented:
You're welcome.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.