How MySQL Evaluates Expressions Within SUM Function

Rama Giri
Updated on 22-Jun-2020 05:31:13

149 Views

When we include an expression within SUM() function then MySQL evaluates it for each row of data and the total result is returned. To understand it, consider the following example of table ‘employee’, having the following details −mysql> Select * from Employee; +----+--------+--------+ | ID | Name   | Salary | +----+--------+--------+ | 1  | Gaurav | 50000  | | 2  | Rahul  | 20000  | | 3  | Advik  | 25000  | | 4  | Aarav  | 65000  | | 5  | Ram    | 20000  | | 6  | Mohan  | 30000  | | 7  | Aryan  | ... Read More

Role of Margin Property with Value Auto in CSS

Arjun Thakur
Updated on 22-Jun-2020 05:31:06

216 Views

The margin property with value auto is used to horizontally center the element within its container. You can try to run the following code to implement margin: auto;ExampleLive Demo                    div {             width: 200px;             margin: auto;             border: 2px dashed blue;          }                     This is demo text                This is horizontally centered because it has margin: auto;           Output

MySQL Conditional Expression within SUM Function

Samual Sam
Updated on 22-Jun-2020 05:30:20

159 Views

As we know that, by using a conditional expression within SUM() function we can get the number of rows that meet the condition. So, in this case, MySQL evaluates to 1 each time the condition is true and 0 each time it is false.To understand it, consider the following example of table ‘employee’, having the following details −mysql> Select * from Employee; +----+--------+--------+ | ID | Name   | Salary | +----+--------+--------+ | 1  | Gaurav | 50000  | | 2  | Rahul  | 20000  | | 3  | Advik  | 25000  | | 4  | Aarav  | 65000  | ... Read More

Different Modes of Parameters in MySQL Stored Procedure

radhakrishna
Updated on 22-Jun-2020 05:29:17

2K+ Views

Parameters make the stored procedure more useful and flexible. In MySQL, we have the following three kinds of modes −IN modeIt is the default mode. When we define an IN parameter in a stored procedure, the calling program has to pass an argument to the stored procedure. The value of an IN parameter is protected which means that even the value of the IN parameter is changed inside the stored procedure; its original value is retained after the stored procedure ends.OUT modeThe value of an OUT parameter can be changed inside the stored procedure and its new value is passed back to the calling ... Read More

Find Most Recent and Oldest Date Using MySQL MAX and MIN Functions

Ankith Reddy
Updated on 22-Jun-2020 05:27:53

7K+ Views

For getting the most recent date from a table, we need to provide the name of the column, having a date as value, as the argument of MAX() function. Similarly, forgetting the oldest date from a table, we need to provide the name of a column, having a date as value, as the argument of MIN() function. To understand it, consider the following example of table ‘Collegedetail’, having the following details −mysql> Select * from collegedetail; +------+---------+------------+ | ID   | Country | estb       | +------+---------+------------+ | 111  | INDIA   | 2010-05-01 | | 130  | ... Read More

Treat Hexadecimal Value as a Number

Sai Nath
Updated on 22-Jun-2020 05:26:48

104 Views

For treating the hexadecimal value as a number, we can use the CAST(… AS UNSIGNED) function. Following example will demonstrate it −mysql> Select 0x54, CAST(0x54 AS UNSIGNED); +------+------------------------+ | 0x54 | CAST(0x54 AS UNSIGNED) | +------+------------------------+ | T    |                     84 | +------+------------------------+ 1 row in set (0.01 sec)

Create MySQL Stored Procedure with IN Parameter

Smita Kapse
Updated on 22-Jun-2020 05:26:03

450 Views

To make it understand we are using the table named ‘student_info’ which have the following values −mysql> Select * from student_info; +-----+---------+------------+------------+ | id  | Name    | Address    | Subject    | +-----+---------+------------+------------+ | 101 | YashPal | Amritsar   | History    | | 105 | Gaurav  | Jaipur     | Literature | | 110 | Rahul   | Chandigarh | History    | | 125 | Raman   | Shimla     | Computers  | +------+--------+------------+------------+ 4 rows in set (0.00 sec)Now, with the help of the following query, we will create a stored procedure ... Read More

Create MySQL Stored Procedure with INOUT Parameter

Nishtha Thakur
Updated on 22-Jun-2020 05:25:09

1K+ Views

Following example will demonstrate MySQL stored procedure with INOUT parameter −mysql> DELIMITER // ; mysql> Create PROCEDURE counter(INOUT count INT, IN increment INT)     -> BEGIN     -> SET count = count + increment;     -> END // Query OK, 0 rows affected (0.03 sec)Here, ‘count’ is the INOUT parameter, which can store and return values and ‘increment’ is the IN parameter, which accepts the values from user.mysql> DELIMITER ; mysql> SET @counter = 0; Query OK, 0 rows affected (0.00 sec) mysql> CALL counter(@Counter, 1); Query OK, 0 rows affected (0.00 sec) mysql> Select @Counter; ... Read More

Role of Margin Property with Value Inherit Using CSS

Giri Raju
Updated on 22-Jun-2020 05:24:06

438 Views

The margin property with value inherit is used to inherit an element from the parent element. You can try to run the following code to implement margin: inherit;ExampleLive Demo                    div {             border: 2px solid blue;             margin-left: 50px;          }          p.ex1 {             margin-left: inherit;          }                     Inheriting left margin from the parent element                This is demo text with inherited left margin.           Output

List of Stored Procedures and Functions in MySQL Database

Sreemaha
Updated on 22-Jun-2020 05:22:34

283 Views

We can see the list of the stored procedure and stored functions in a particular database by using the following query on INFORMATION_SCHEMA.ROUTINES as follows −mysql> SELECT ROUTINE_TYPE, ROUTINE_NAME FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA = 'query'; +--------------+--------------+ | ROUTINE_TYPE | ROUTINE_NAME | +--------------+--------------+ | PROCEDURE    | allrecords   | | FUNCTION     | Hello        | +--------------+--------------+ 2 rows in set (0.04 sec)The above query returns the procedure named ‘allrecords’, and function named ‘Hello’ which are stored in the database named ‘query’.

Advertisements