Jump to content

Recommended Posts

Hello, I have a process that pulls a flat file into mysql. Certain rows have a column that has a code value that is a string. Most rows do not. I have written a query to select the ones that do not

 

!=""

 

However the columns with the empty string are still appearing. I believe this is because there IS some sort of character in that column. When I look at the results in phpMyAdmin I see it gives the td for that empty column as

 

<td class="">

<br>

</td>

 

So Im guessing a new line character is being stored in the db? Any idea how to prevent this from getting in or how to query against its existance?

Link to comment
https://forums.phpfreaks.com/topic/241258-empty-varchars-not-responding-to/
Share on other sites

Post your query string, and the code that displays the results. You can probably use either the MySQL TRIM() or PHP trim() function if there's whitespace in the field (preferably MySQL's function).

 

EDIT: Actually, if that turns out to be cause, you can run one query to trim all the existing values, then do as xyph suggested and TRIM() them on insert if you want to.

Trimming worked. I have no idea why I didnt think of that. Turns out the binary character 0a was being left behind. I believe its fixed now. Thanks.

 

 

EDIT:

Just for giggles and in case it comes up, how would I run that query to modify it? I can not for the life of me select the rows that have the binary 0a in them.

 

I try WHERE BINARY(`code`)='0a' but that doesnt work. Obviously WHERE `code`='' wouldnt either.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.