troubleshooting Question

How do I incorporate CASE into this SELECT?

Avatar of Bruce Gust
Bruce GustFlag for United States of America asked on
MySQL Server
4 Comments4 Solutions21 ViewsLast Modified:
Here's a breakdown of what I need to do:

INSERT into tasks_master_tracker_idb (   
`DIRECTION`,   
`PROD_INBOUND_TRANSPORT_ADDR`, 
`PROD_OUTBOUND_TRANSPORT_ADDR`)
SELECT 
t.DIRECTION,
rt.TRANSPORT_4
FROM tasks t 
LEFT JOIN requirements_transport rt ON t.ID = rt.INTID__ and rt.ID = (select MAX(ID) from requirements_transport where INTID__ = t.ID)
WHERE  (t.INTID is not null and t.CUSTID is not null ) 
AND t.ID not in (select TASK_ID from tasks_master_tracker_idb)

If "t.DIRECTION" is "INBOUND" than I need to insert the "rt.TRANSPORT_4" value into, "PROD_INBOUND_TRANSPORT_ADDR." If "t.DIRECTION" is "OUTBOUND," than I need to insert the "rt.TRANSPORT_4" value into "PROD_OUTBOUND_TRANSPORT_ADDR."

And than if "t.DIRECTION" is "MULTIDIRECTIONAL," than I need to insert the "t.DIRECTION" value into both "PROD_INBOUND_TRANSPORT_ADDR" and "PROD_OUTBOUND_TRANSPORT_ADDR."

I'd like to think that there's a way I can deploy a series of CASES to get that done, but I'm not sure how to pull it off.

How can I do what needs to be done?

I'm running version 8.0.21 of MySQL
ASKER CERTIFIED SOLUTION
Kent Olsen
Data Warehouse / Database Architect

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

Join our community to see this answer!
Unlock 4 Answers and 4 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 4 Answers and 4 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