Avatar of Bruce Gust
Bruce Gust
Flag for United States of America asked on

How do I incorporate CASE into this SELECT?

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)

Open in new window

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
MySQL Server

Avatar of undefined
Last Comment
Bill Prew

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Kent Olsen

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Bill Prew

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Peter Chan

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Bill Prew

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Your help has saved me hundreds of hours of internet surfing.
fblack61