Categories
Feature Story MySQL

MySQL JSON Operations | Advantages and Limitations

JSON’s popularity has risen steadily since its inception nearly 15 years ago. JSON is used for data exchange by the vast majority of public Web services today. JSON functions as a string and are useful for sending data across a network. You must, however, convert it into a JavaScript object first. After that, you can […]

Categories
MySQL

Reset auto increment values in MySQL

When you assign one field as a primary key you can use auto-increment attribute to that field. It generates unique identity for the row inserting a unique auto increment value. You can also reset auto increment values. For example if a table has 5 rows and you insert another row then the automatic value for […]

Categories
MySQL

MySQL Transaction

Using MySQL you can COMMIT a statement and ROLLBACK to manage transaction. While adding a data into two or more tables where one primary key for one table is the foreign key of another table it may happen sometimes that after adding data into first table MySQL failed to add data into second table due […]

Categories
MySQL

MySQL – Find and Replace text in a table

Using ‘replace’ you can find and replace text of a column in a table. Example of Replace text: UPDATE `tbl` SET `field_name` = replace(field_name, ‘old_text’, ‘new_text’);

Categories
MySQL

MySQL INSERT statement

To insert data into tables you can use MySQL INSERT statement. Simple syntax of MySQL INSERT: INSERT INTO table(column1,column2..) VALUES (value1,value2,..), (value1,value2,..); You can also insert from another table also i.e. clone: INSERT INTO tbl_1 SELECT * FROM tbl_2;

Categories
MySQL

MySQL LIKE Operator

Using MySQL LIKE operator you can search based on patterns. It is used in the WHERE clause in SELECT statement. This basically use two characters for using the MySQL LIKE operator: ‘%’ – allows you to match zero or more characters‘_’ – allows you to match any single character For searching the first character starts […]

Categories
MySQL

MySQL DELETE Statement

Using MySQL delete state you can delete table data. With a single delete statement you can delete one or more tables data at a time. Example of MySQL DELETE: DELETE FROM users WHERE status = 0; For multiple table: DELETE users, orders FROM users, orders WHERE users.user_id = orders.user_id AND users.status = 0; TRUNCATE TABLE […]

Categories
MySQL

Mysql Query tips & tricks

Few Mysql queries that will help you develop websites and resolve complex codes. Here are few Mysql Query tips: Finding 2nd highest salary in employee table SELECT MAX(`salary`) from tbl where `salary` < (select MAX(`salary`) from tbl); Mysql order by FIELD SELECT * FROM tbl ORDER BY FIELD(first_name,’John’) desc, FIELD(last_name,’Doe′) ASC; Show category-parent category SELECT […]

Categories
MySQL

Subquery in MySQL

Subquery in MySQL means Query inside another query on SELECT, INSERT, UPDATE or DELETE. A subquery must be enclosed with parentheses and can be used anywhere in an expression. The main advantages of subqueries is that it allow queries that are structured so that, it is possible to isolate each part of the statement and […]

Categories
MySQL

Maintaining MySQL Database Tables

To maintain MySQL Database tables efficiently you need to analysis, optimize, check and repair database tables frequently. Tips for Maintaining MySQL Database Tables: Analyze table: analyze the table for optimize. ANALYZE TABLE table_name; Optimize table: avoid defragmenting problem. OPTIMIZE TABLE table_name; Check table: check if something wrong happen to the database server. CHECK TABLE table_name; […]