troubleshooting Question

Why does this continue to INSERT when it should merely UPDATE?

Avatar of Bruce Gust
Bruce GustFlag for United States of America asked on
PHPMySQL Server
6 Comments2 Solutions24 ViewsLast Modified:
Here's my SQL:

INSERT into tasks_master_tracker_idb (
CLIENT_CONTACT, COMPLEXITY, CREATED_BY, CUSTID, DIRECTION,
INTEGRATION_ID, INTEGRATION_NAME, INTEGRATION_STATUS, INTEGRATION_TYPE, VENDOR
)
   SELECT t.CLIENT_CONTACT, t.COMPLEXITY, t.CREATED_BY, t.CUSTID, t.DIRECTION,
   t.INTID, t.NAME, t.STATUS, t.PROJ_TYPE, t.VENDOR 
   FROM
   tasks t
   WHERE 
   t.CUSTID='DPR01'
   AND
   t.INTID='INT0001'
ON DUPLICATE KEY UPDATE
CLIENT_CONTACT = (SELECT t.CLIENT_CONTACT FROM tasks t WHERE t.CUSTID='DPR01' AND t.INTID='INT0001'),
COMPLEXITY = (SELECT t.COMPLEXITY FROM tasks t WHERE t.CUSTID='DPR01' AND t.INTID='INT0001'),
CREATED_BY = (SELECT t.CREATED_BY FROM tasks t WHERE t.CUSTID='DPR01' AND t.INTID='INT0001'),
CUSTID = (SELECT t.CUSTID FROM tasks t WHERE t.CUSTID='DPR01' AND t.INTID='INT0001'),
DIRECTION = (SELECT t.DIRECTION FROM tasks t WHERE t.CUSTID='DPR01' AND t.INTID='INT0001'),
INTEGRATION_ID = (SELECT t.INTID FROM tasks t WHERE t.CUSTID='DPR01' AND t.INTID='INT0001'),
INTEGRATION_NAME = (SELECT t.NAME FROM tasks t WHERE t.CUSTID='DPR01' AND t.INTID='INT0001'),
INTEGRATION_STATUS = (SELECT t.STATUS FROM tasks t WHERE t.CUSTID='DPR01' AND t.INTID='INT0001'),
INTEGRATION_TYPE = (SELECT t.PROJ_TYPE FROM tasks t WHERE t.CUSTID='DPR01' AND t.INTID='INT0001'),
VENDOR = (SELECT t.VENDOR FROM tasks t WHERE t.CUSTID='DPR01' AND t.INTID='INT0001')
My quandary is the fact that I've got DPR01 | INT001 already in the database. Therefore, I'm expecting an UPDATE. Instead, it keeps inserting a new row into the "tasks_master_tracker_idb" table.

Why?

What am I missing?
EXPERT CERTIFIED SOLUTION
ste5an
Senior Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros