Update with join table
To update a table with a condition within other table (to join table), you can use this statement 1 2 3 UPDATE table1 a, table2 b SET a.field6 = value WHERE a.field1 = b.field1 AND b.field2 = value2
View ArticleMySQL database auto backup on windows
To backup mysql database (all databases) can use this batch file Then you can compile the .bat file to become .exe file so that the password is hidden. Download bat to exe converter from CNET download...
View ArticleReset root password for MySQL on windows
If you have problem accessing your MySQL database with this error ERROR 1045: Access denied for user: ‘root@localhost’ (Using password: NO) You can try reset your root password with the following...
View ArticleTransparent Data Encryption (TDE)
To secure the data by encryption at data at database level. This will be full done by database application and won’t affect the application level. Almost all popular RDBMS provide this feature but...
View ArticleCheck value exist in a table but not in another table
SQL to check a value exist in one table but not in another. SELECT t1.name FROM table1 t1 LEFT JOIN table2 t2 ON t2.name = t1.name WHERE t2.name IS NULL or this (not tested) SELECT * FROM B WHERE NOT...
View ArticleDelete records from multiple tables
This is sample query to delete record from multiple tables. Specify all joined tables to get the list but can specify records in which tables to be deleted. DELETE t1, t2 FROM t1 INNER JOIN t2 INNER...
View ArticleDisable ONLY_FULL_GROUP_BY in MySQL version 5.7
To disable ONLY_FULL_GROUP_BY mode you can use the following command SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY','')); Or can update in phpmyadmin by clicking on “Variables”...
View ArticleCodeigniter bulk insert to database
If you are to insert hundreds or thousands of records, please use bulk insert. Avoid call insert query in loop. $data = array( array( 'title' => 'My title' , 'name' => 'My Name' , 'date' =>...
View ArticleTruncated incorrect DECIMAL value: ”
This error message is not helpful at all. There are similar error to this for DOUBLE etc instead of DECIMAL value. I got this error when running a simple query like below in MySQL. update table_1set...
View Article