MySQL, add a string in start of all column values
Recently I come to know a very cool function in mysql that is CONCAT. There is a table in mysql database known as tbl_clients. Structure of this table is as follows:
id int(11) auto_increment, P.K
. . . .
there were more than 500 clients having website homepage URLs and all URLs were without “http://”. like
So requirement was to add “http://” to every URL so it can be crawled by crawler.
So first solution to this is
UPDATE tbl_clients SET website =CONCAT('http://',website);
If there are some columns that already have “http://” and we do not want to prepend “http://” then we can do like this
UPDATE tbl_clients SET website=CONCAT('http://',website)
WHERE website NOT LIKE 'http://%';