Solved

MySQL Query Mystery

Posted on 2012-04-03
9
292 Views
Last Modified: 2012-06-27
Hi,

I am really hoping someone would be able to shed some light on this very perplexing issue for me about a query error I am getting.

I am able to run a MySQL query successfully on my local machine but when I try to run it on the remote web hosting MySQL server, I get an error.

THE ERROR MESSAGE:

[Err] 1048 - Column 'nXproject_ID' cannot be null


The Query:

The LEFT JOIN below gives a result of have a return of zero query results as the tJobReview currently has no entries with the specified nXproject_ID, and thus the nXproject_ID will be a NULL value.



      SELECT ifnull(a.total_ass_completed,0) num_ass_completed

                      FROM tXproject
                  LEFT JOIN tXquantify
                      ON tXqantify.nXquantify_ID = tXproject.nXquantify_ID
      
      LEFT JOIN
      (SELECT sJobStatus, nXproject_ID, count(1) total_ass_completed
      FROM tJobReview
      WHERE nXproject_ID =  'A0C145DF-0B4E-A0F8-E25BDE92BB20A1E5'
      AND sJobStatus = "Completed"
      ) a
      ON tXproject.nXproject_ID =a.nXproject_ID

      
      WHERE tXproject.nXproject_ID = 'A0C145DF-0B4E-A0F8-E25BDE92BB20A1E5'



When I run the query on my local machine, I get no errors and so if there are no entries inside the tJobReview with the specified nXproject_ID, 'num_ass_completed' = 0.

When I try to run the same query on the remote host server, I get the error:

 [Err] 1048 - Column 'nXproject_ID' cannot be null

Why is this the case?

Please help me as I have been trying to solve this for the last 48 hours now. I will be very grateful Thank you.
0
Comment
Question by:CFbubu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 37803197
What version of mySQL? A quick search suggests it might be a bug that was patched in 5.1

http://bugs.mysql.com/bug.php?id=2508
http://bugs.mysql.com/bug.php?id=31450
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 37803221
Yes, I would think you are seeing two different versions of MySQL.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 37803271
Yeah that seems the most likely explanation.  Run a query on both to dump the version

<cfquery name="qVersion" datasource="yourDSN">SELECT @@version AS Version</cfquery>
<cfdump var="#qVersion#">
0
Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

 

Author Comment

by:CFbubu
ID: 37803412
Ok...These are the version numbers I got:

On my local machine:

5.5.12

On the remote server:

5.0.77

So, is the version on my local machine the correct one? If so, does that mean that if I somehow manage to upgrade the mySQL on the remote machine to the same version as on my local machine, my query wont be broken anymore?....

Of so...how do I change the MySQL on my hosting emote machine?

Thanks so much....I have been getting so frustrated and down with the mysterious issue...
0
 
LVL 52

Expert Comment

by:_agx_
ID: 37803589
Yeah the local version is much newer than the remote one 5.0.x (the fix was in 5.1). In theory yes upgrading will fix the issue. You can always download a copy of the remote database and try it out locally. Create a separate dsn pointing to the db copy. If it gives the same error locally, try upgrading it and see if that fixes the problem. If it does, upgrade the remote db too.  Always make backups first to avoid data loss!

how do I change the MySQL on my hosting emote machine?


That all depends on the remote machine. But here are some tips for upgrading.
http://dev.mysql.com/doc/refman/5.1/en/upgrading.html
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 37803616
If you're on shared hosting, you probably can't change it.  To get the version you have at home, you may have to change servers or even hosting.
0
 

Author Comment

by:CFbubu
ID: 37840484
Hi  _agx_ and DavidBaldwin,

So sorry I took so long to confirm if the suggested solution worked. I just took ALOT of trouble to and few days to get my Hosting company to 'upgrade' my version of MySQL to a version 5.1 above.

I tried the query again after the MySQL version on the remote host was updated, and YES! It works!

Thanks for your very quick insight on this mystery of mine. Without your help, I would not have been able to resolve it. Again, sorry for the delayed response as I had to go thru many days of waiting and trouble to get my hosting company to help me out before I could test your solution out.
0
 

Author Closing Comment

by:CFbubu
ID: 37840488
Thanks so very much!
0
 
LVL 52

Expert Comment

by:_agx_
ID: 37854233
Sorry, just saw this response.  No worries. Changes are often .. challenging... when a hosting company's involved.  Just glad to hear they finally did upgrade it for you!
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

752 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