Solved

MySQL Query Mystery

Posted on 2012-04-03
9
290 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
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
Back Up Your Microsoft Windows Server®

Back up 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.

 

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Select Query - Group By Function Producing Unexpected Results 8 34
sort in mysql based off of query param 4 29
remote mysql 8 35
MySql Recovery 2 32
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

679 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