0

I have a table with contact codes. When contact code is not specified there are ^^ in the empty cell. If specified should be: ^Code123^,^Code321^,^Code987^

I want to update this cell, but I dont know how to rewrite empty cell with ^^?

With my query I get this result ^^,^Code123^,^Code321^,^Code987^. How to delete ^^ when updating cell?

$sql6 = "UPDATE contacts 
         SET clicks_c=IF(clicks_c='', 
                         '^".$url_name."^',
                         CONCAT_WS(',',clicks_c,'^".$url_name."^')) 
         WHERE id_c='".$row_id."'";
Barmar
  • 741,623
  • 53
  • 500
  • 612
user3514052
  • 418
  • 4
  • 18

1 Answers1

1

If an empty cell contains ^^, you need to test for that in your IF(). Change:

IF(clicks_c='',

to:

IF(clicks_c IN ('', '^^),

Then it will replace ^^ with a nonempty code, instead of concatenating to it.

Barmar
  • 741,623
  • 53
  • 500
  • 612