Find and Replace Text in MySQL with an SQL query can be quite easy, using the command REPLACE: UPDATE TABLE SET FIELD =REPLACE(FIELD, 'some-data', 'other-data');
Add this to the beginning of dump SET AUTOCOMMIT = 0; SET FOREIGN_KEY_CHECKS=0; and this to the end SET FOREIGN_KEY_CHECKS = 1; COMMIT; SET AUTOCOMMIT = 1;
If the query returns a text type, but we need to obtain the numerical values of type, you can just add *1 to column you need to be int(or numeric.) Example: We have column category, in this column data has next format: 1,2,34,14,4, type of column – char, but we need get the first number and sort table by it. SELECT SUBSTRING(category,1,LOCATE(',',category)-1) ...
Hi, today I ran into a problem - I had to use the MAX() function while Inserting data into database. I write a simple query: INSERT INTO `table` (row1,row2) VALUES(`sample`,MAX(row2)+1) And I got an error #1111 – Invalid use of group function So I start to think and find the right way to compose my query: INSERT INTO `table` (row1,row2) VALUES(`sample`,(SELECT ...