SQL: Replace All HTTP Links/URLs with HTTPS

May 6th, 2023

The query is being simulated in one of my tables here through PHPMyAdmin.

Here’s a short snippet that I recently used to replace a bunch of old HTTP links with the now-supported HTTPS.

UPDATE table
SET link = REPLACE(link, 'http://', 'https://')

It’s that simple! Of course, if you needed to go the other way then you would just swap HTTP and HTTPS like so:

UPDATE table
SET link = REPLACE(link, 'https://', 'http://')


Leave a Reply

Your email address will not be published. Required fields are marked *