Skip to content

Instantly share code, notes, and snippets.

@atapatel
Last active July 31, 2020 11:48
Show Gist options
  • Save atapatel/6bbf065ebbdac5623ac756798395861b to your computer and use it in GitHub Desktop.
Save atapatel/6bbf065ebbdac5623ac756798395861b to your computer and use it in GitHub Desktop.
select * from ((SELECT disp_id,
'both',
'All',
'INACTIVE',
now() as created_at,
now() as updated_at,
NULL
FROM dispensaries
UNION All
SELECT disp_id,
'cod',
'Cash On Delivery',
'INACTIVE',
now() as created_at,
now() as updated_at,
NULL
FROM dispensaries
UNION ALL
SELECT disp_id,
'card',
'Card On Delivery',
'INACTIVE',
now() as created_at,
now() as updated_at,
NULL
FROM dispensaries
))as x order by x.disp_id;
@atapatel
Copy link
Author

SELECT concat(disp_id,payment_method) from dispensaries

@atapatel
Copy link
Author

update disp_payment_methods set status='ACTIVE' where concat(disp_id,payment_slug) in (SELECT concat(disp_id,payment_method) from dispensaries)

@atapatel
Copy link
Author

update disp_payment_methods set status='ACTIVE' where concat(disp_id,payment_slug) in (
SELECT concat(disp_id,payment_method) from dispensaries
)
OR
concat(disp_id,payment_slug) in (
SELECT concat(disp_id,IF(payment_method='both','cod')) from dispensaries where payment_method='both'
)
concat(disp_id,payment_slug) in (
SELECT concat(disp_id,IF(payment_method='both','card')) from dispensaries where payment_method='both'
)

@atapatel
Copy link
Author

update disp_payment_methods set status='ACTIVE' where concat(disp_id,payment_slug) in (
SELECT concat(disp_id,payment_method) from dispensaries
)
OR
concat(disp_id,payment_slug) in (
SELECT concat(disp_id,IF(payment_method='both','cod')) from dispensaries where payment_method='both'
)
OR
concat(disp_id,payment_slug) in (
SELECT concat(disp_id,IF(payment_method='both','card')) from dispensaries where payment_method='both'
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment