Solved

Two table update just isn't working in MySQL.  No updates!

Posted on 2016-08-16
1
80 Views
Last Modified: 2016-08-16
First the wide code.
I included a select that confirms the fields are set.  With / without the table qualifier doesn't make a difference, so it appears.
UPDATE   zModem_Census     z
     ,   ModemConfig       mc
   SET   z.have_plan_rates_set = 
           ( CASE WHEN NOT ISNULL(`mc`.`intl_rate_plan_id`)   AND NOT `mc`.`intl_rate_plan_id`=''   AND NOT `mc`.`intl_rate_plan_id`   = 'Unassigned' THEN 1 ELSE 0 END 
         AND CASE WHEN NOT ISNULL(`mc`.`dom_rate_plan_id`)    AND NOT `mc`.`dom_rate_plan_id`=''    AND NOT `mc`.`dom_rate_plan_id`    = 'Unassigned' THEN 1 ELSE 0 END )
  WHERE  z.modem_config_id = mc.modem_config_id
    AND  z.posting_period = 'Aug 2016'  ;

SELECT (CASE WHEN NOT ISNULL(`intl_rate_plan_id`)   AND NOT `intl_rate_plan_id`=''   AND NOT `intl_rate_plan_id`   = 'Unassigned' THEN 1 ELSE 0 END 
         AND CASE WHEN NOT ISNULL(`dom_rate_plan_id`)    AND NOT `dom_rate_plan_id`=''    AND NOT `dom_rate_plan_id`    = 'Unassigned' THEN 1 ELSE 0 END) AS HaveSet
FROM ModemConfig  ;

Open in new window

I've also (originally) tried using JOIN syntax:
  UPDATE zModem_Census     z
  JOIN   ModemConfig       mc
    ON   z.modem_config_id = mc.modem_config_id
   SET   have_plan_rates_set = 
             CASE WHEN NOT ISNULL(`intl_rate_plan_id`)   AND NOT `intl_rate_plan_id`=''   AND NOT `intl_rate_plan_id`   = 'Unassigned' THEN 1 ELSE 0 END 
         AND CASE WHEN NOT ISNULL(`dom_rate_plan_id`)    AND NOT `dom_rate_plan_id`=''    AND NOT `dom_rate_plan_id`    = 'Unassigned' THEN 1 ELSE 0 END
  WHERE  z.posting_period = var_posting_period  ;
  COMMIT ;

Open in new window

Parentheses don't seem to make a difference either.
What am I missing here?

Thanks!
0
Comment
Question by:Ralph
1 Comment
 

Accepted Solution

by:
Ralph earned 0 total points
ID: 41758426
Never mind!  No Aug 2016 data yet.  I should have been using Aug 2015.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

813 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

8 Experts available now in Live!

Get 1:1 Help Now