0

I'm attempting to query on a field/column/table in a MySQL DB where the field type is varchar, but some values contains spaces. In my query, I tried to put the exact string to match on in single quotes in a where clause. However, the only rows that are returned are the strings that do not contain spaces.

Here are the values stored in the table/column:

enter image description here

Here is the query and the result that is only returning fields without spaces:

enter image description here

I expected to find a row for "New Business", a row for "Monetary Endorsement", etc. Any idea on how I can modify my query to return the desired fields? Thanks for your help in advance!

1 Answer 1

2

Maybe the other values have leading or trailing spaces. You can either use one of the suggestion below:

1.) Use TRIM()

WHERE TRIM(PTD_TRANS_TYPE) = 'NEW BUSINESS'

2.) Use LIKE

WHERE PTD_TRANS_TYPE LIKE '%NEW BUSINESS%'

Here's a Demo.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.