Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MySQL Query Mystery

Posted on 2012-04-03
9
Medium Priority
?
302 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 2000 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 84

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
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 

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 84

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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

885 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