Link to home
Start Free TrialLog in
Avatar of CFbubu
CFbubu

asked on

MySQL Query Mystery

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.
ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, I would think you are seeing two different versions of MySQL.
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#">
Avatar of CFbubu
CFbubu

ASKER

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...
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
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.
Avatar of CFbubu

ASKER

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.
Avatar of CFbubu

ASKER

Thanks so very much!
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!