mrherman Posted August 5, 2010 Share Posted August 5, 2010 I have a MySQL table with a field called student_id. This table is populated by a text file. For some rows, a student id is not imported. I would like to delete these rows like this: DELETE FROM mytable WHERE student_id = "" ; However, this does not work. Nothing seems to work. I have tried a lot of things to determine what is in this this field. In the table structure it is CHAR(9) NULL is ALLOWED How can I determine what is in this field so that I can delete a row based on the field's contents or non-contents. Thank you. FOLLOW-UP -- Whatever is in the field has a length of 2. When I issue this select, it brings up the rows appropriately: SELECT * FROM mytable WHERE LENGTH(student_id) = 2 ; Quote Link to comment https://forums.phpfreaks.com/topic/209920-mysql-cell-looks-blank-but-is-something-in-the-cell/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 5, 2010 Share Posted August 5, 2010 They are probably crlf \r\n You can use the mysql ORD() function in a SELECT query to display what value the characters are. What method are you using to import the data, because you should probably validate (or trim()) what is being imported. Edit: Also, you can probably use the mysql TRIM() function or smiler in an UPDATE query to remove the characters once you find what they are (you likely have them on the end of actual data if they are the \r\n from a text file.) Quote Link to comment https://forums.phpfreaks.com/topic/209920-mysql-cell-looks-blank-but-is-something-in-the-cell/#findComment-1095698 Share on other sites More sharing options...
mrherman Posted August 5, 2010 Author Share Posted August 5, 2010 Well, thank you! Yes, you were correct about the contents of these cells. I have never used ORD() before, and I did some research and learned a lot. I've imported thousands of text files, but I have never (knowingly) run into this, although this import had to be done a little differently. My appreciations again for you help, PFMaBiSmAd. I'll remember ORD()! Quote Link to comment https://forums.phpfreaks.com/topic/209920-mysql-cell-looks-blank-but-is-something-in-the-cell/#findComment-1095748 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.