query

MySQL: Sorting Alpha-Numeric values with Example

In MySQL, the ORDER BY keyword is used for sorting the records ascending(ASC) or descending(DESC), by default it will be on ascending. The default ORDER BY statement will not work with Alpha-Numerical values(The values is mixed of both numbers and strings). To resolve this problem we can use ABS() MySQL function.

Drupal 6: Database Select, Insert, Update and Delete Query with example

In Drupal system have its own query builder it will create a query on Drupal way and sent to the Database server. To run a Database query we have built our condition on a specific format. The function db_query() function helps us to achieve run database queries in Drupal 6. The below is the syntax and example using a different type of Database queries.

Drupal 7: Database Aggregate functions (SUM, MIN, MAX, COUNT, AVG,..)

The MySQL database query supports aggregate functions to retrieve values from the database. In our custom query, we can able to add aggregate queries. The function addExpression() takes object of database query to aggregate results in db_select(). The below example will demonstrate the usage of aggregate functions.

Drupal 7: Database query with MySQL Date functions

The MySQL is the database which stores any type of data in Database. Using the MySQL we can able to store date-related fields. The MySQL will support Date functions to retrieve and format database date field values. In Drupal also we can able to add date functions in our queries with help of where() function in the database object. The below is the syntax and example of usage of the where() function.

Drupal 8 : How to use MERGE(INSERT+UPDATE) query with Syntax and Example

MERGE is the short hand Drupal database statement used to perform both INSERT and UPDATE functionality in same code. It Will check whether record is already exits with given condition, yes then update based on condition otherwise insert a new record. The merge() is a function of Drupal 8 core class used for MERGING record based on condition records. Below is syntax and example of how to use MERGE statements in Drupal 8.

Initial Table be like:

Related Blogs:

Drupal 8 : How to use DELETE query with Syntax and Example

Using the object of core Drupal class we can perform database queries. Delete is the data deletion query used to remove data from Database based on conditions. The delete() is a function of Drupal 8 core class used for remove records. Below is syntax and example of how to use DELETE query in Drupal 8.

Before Delete Table be like:

EMPLOYEE_ID EMPLOYEE_NAME EMPLOYEE_AGE
CE 001 Mohan 20
CE 002 Dinesh 17
CE 003 Kumar 25

After Performing delete Query table records like:

Related Blogs:

Drupal 8 : How to use UPDATE query with Syntax and Example

UPDATE is the Data Manipulation Language(DML) query in Database management system. Using the object of core Drupal class we can perform database queries in Drupal 8. Update is the data modifying query used to change data in Database. The update() is a function of Drupal 8 core class used for update records. Below is syntax and example of how to use INSERT query in Drupal 8.

Before Update Record in Table be like:

EMPLOYEE_ID EMPLOYEE_NAME EMPLOYEE_AGE
CE 001 Mohan 20
CE 002 Dinesh 17
CE 003 Kumar 25

 

Related Blogs:

Drupal 8 : How to use SELECT query with Syntax and Example

Using the object of core Drupal class we can perform database queries. Select is the data retrieval query that has been done with help of select() of Drupal 8 core class. Below sample show how to use select query in Drupal 8.

Output:

EMPLOYEE_ID EMPLOYEE_NAME EMPLOYEE_AGE
CE 001 Mohan 20
CE 002 Dinesh 17
CE 003 Kumar 25

Related Blogs

Drupal 8 : How to use INSERT query with Syntax and Example

Insert is the Data Manipulation Language(DML) query in Database management system. Using the object of core Drupal class we can perform database queries in Drupal 8. Insert is the data saving query used to store data to Database. The insert() is a function of Drupal 8 core class used for insert records. Below is syntax and example of how to use INSERT query in Drupal 8.

Before Insert Table be like:

EMPLOYEE_ID EMPLOYEE_NAME EMPLOYEE_AGE
CE 001 Mohan 20
CE 002 Dinesh 17

 

After Performing Insert Query table records like:

Related Posts:

MySQL : Importing Database Dump / Backup to MySQL Server

We can able to make dump of MySQL database as .sql file[Refer: MySQL : Backup / Dump MySQL Database in Windows and Ubuntu]. By using the dump of sql file we can import them to MySQL database using the mysql command "use FILE_NAME.sql". This will import entire database source file into database schemas and dataset to schemas. Import time is based on Dump size.