MySql Archive

MySQL, add a string in start of all column values

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: [crayon-5b74fd7bbb824081831449/] there were more than 500 clients having website homepage URLs and all URLs

Mysql – Regex Operator

In Mysql if we want to run a query that has condition like record should start with ‘D’ or ‘E’. Normally we use Like Operator. select * from tablename where name like 'D%' OR name like 'E%' But using REGEX in MySql we can get same result without using OR in query select * from

Mysql – disabling and enabling foreign key checks

Recently I was working on a project in which I have to truncate tables in database. But due to foreign key constraints MySQL was throwing errors. So the solution I found was to disable Foreign Key constraints temporarily delete all data and then again enable the foreign keys. Disable foreign key checks. SET FOREIGN_KEY_CHECKS=0; Enable

MySql – search and replace a string in a column

If we and to search some specific string inside our column data and replace it with other string then we can use replace query of MySql. Suppose table name is ‘users’ and we want to search city column with a value ‘London’ and replace it with ‘New York’ [crayon-5b74fd7bbebe8369163927/]