Solved

PreparedStatement update does not update on NULL values

Posted on 2014-04-06
3
42 Views
Last Modified: 2016-06-04
Hi Experts

I am trying to update a field with NULL values without success, but If I put an empty String the update works. The problem with putting an empty string is - my column field "fruitname" accepts unique values. I am using JDBC. see below what I am trying to do.

update fruits_tbl set uxservernames=concat(fruitname, \r\n'" + fruitname + "') where fruit_id=" +fruit_id)

The columns

fruit_id (INT) PRK | fruitname (VARCHAR(255) | fruitdescr VARCHAR(255)|

The fruitname column can hold a NULL value.

Thank you.
0
Comment
Question by:jw124210
3 Comments
 
LVL 34

Accepted Solution

by:
Dan Craciun earned 95 total points
Comment Utility
CONCAT returns NULL if any of the operators are NULL.

If you want to avoid this, us
CONCAT_WS('\r\n', fruitname, 'peach')

CONCAT_WS will simply skip any NULL values.

HTH,
Dan
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
In my experience MySQL NULL does not match an empty string of zero length.   However if the columns are defined NOT NULL DEFAULT '' an empty string will match.
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Suggested Solutions

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Creating and Managing Databases with phpMyAdmin in cPanel.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now