I have a table like this:
id | shop_id | collection_id | collection_title | product_ids | created_on | updated_on |
---|---|---|---|---|---|---|
20735 | 50 | 263607681176 | Home page | 2021-04-09T01:06:13Z | 2021-04-13T23:26:14Z | |
20736 | 50 | 264253735064 | Summer Collection | 6623623413912,6623624822936,6623625085080,6623624691864,6623624659096,6623623741592,6623623610520,6623623577752 | 2021-04-09T01:06:13Z | 2022-03-30T06:58:34Z |
20737 | 50 | 264253736541 | Winter Collection | 6623624822936,6623625085080,6623624691864,6623624659096 | 2021-04-09T01:06:13Z | 2022-03-30T06:58:34Z |
20738 | 70 | 264253767832 | Under $100 | 6623623413912,6623625085080,6623624822936,6623624790168,6623623905432,6623623872664,6623623839896,6623623774360 | 2021-04-09T01:06:13Z | 2021-04-13T23:26:14Z |
My input ids are:
6623625085080
6623624659096
I want a table like this after a query (passed ids should be removed from the table):
id | shop_id | collection_id | collection_title | product_ids | created_on | updated_on |
---|---|---|---|---|---|---|
20735 | 50 | 263607681176 | Home page | 2021-04-09T01:06:13Z | 2021-04-13T23:26:14Z | |
20736 | 50 | 264253735064 | Summer Collection | 6623623413912,6623624822936,6623624691864,6623623741592,6623623610520,6623623577752 | 2021-04-09T01:06:13Z | 2022-03-30T06:58:34Z |
20737 | 50 | 264253736541 | Winter Collection | 6623624822936,6623624691864 | 2021-04-09T01:06:13Z | 2022-03-30T06:58:34Z |
20738 | 70 | 264253767832 | Under $100 | 6623623413912,6623625085080,6623624822936,6623624790168,6623623905432,6623623872664,6623623839896,6623623774360 | 2021-04-09T01:06:13Z | 2021-04-13T23:26:14Z |
I have already used this query and it works for the single product_ids
in there:
UPDATE collections SET product_ids = TRIM(BOTH ',' FROM REPLACE(CONCAT(',', product_ids, ','), ',6623625085080,', ',')) WHERE FIND_IN_SET('6623625085080', product_ids) AND shop_id = 50;
But, I want to do that by passing multiple product_ids
in a single Update query.
Here you can see this screenshot, that I have tested,
And here is the SQL Fiddle link also: http://sqlfiddle.com/#!9/bba9ff/1