Solved

MySQL Query Mystery

Posted on 2012-04-03
9
280 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
  • 4
  • 3
  • 2
9 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
Comment Utility
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 82

Expert Comment

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

Expert Comment

by:_agx_
Comment Utility
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
 

Author Comment

by:CFbubu
Comment Utility
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 52

Expert Comment

by:_agx_
Comment Utility
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 82

Expert Comment

by:Dave Baldwin
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks so very much!
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

12 Experts available now in Live!

Get 1:1 Help Now