devxlogo

MySQL

Understanding the AVG Function in MySQL

Assume there is a column named MARKS in the table STUDENT_DETAILS, and we need to calculate the average. The following query will be necessary: SELECT AVG(MARKS) AVERAGE FROM STUDENT_DETAILS; This

Figure Out the Length of Text in a Column in MySQL

Considering the following table STOCKPRICE and its details. CREATE TABLE `STOCKPRICE` (`ID` INT(11) NOT NULL,`NAME` TEXT NOT NULL COLLATE ‘utf8_bin’,`PRICE` INT(11) NOT NULL)COLLATE=’utf8_bin’ENGINE=InnoDB; Also, use the following to create sample

Selecting the Max, Min and Sum of Values from a Table in MySQL

Considering the following table STOCKPRICE and its details. CREATE TABLE ‘STOCKPRICE’ (‘ID’ INT(11) NOT NULL,’NAME’ TEXT NOT NULL COLLATE ‘utf8_bin’,’PRICE’ INT(11) NOT NULL)COLLATE=’utf8_bin’ENGINE=InnoDB; Also, use the following to create sample

Getting the Current Date and Time in MySQL

MySQL provides a NOW()?function that returns the current date and time when executed. Command: SELECT NOW() AS ‘CURRENT DATE AND TIME’; Expected output: +————————-+|CURRENT DATE AND TIME |+————————-+| 2018-03-20 19:22:17

Understanding IFNULL in MySQL

MySQL queries can help us work with null values in queries and behave as we need. IFNULL?is a suitable function and can be used where you want to treat null