
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 6705 Articles for Database

149 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

437 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

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

140 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

130 Views
To get some starting number of characters from the data stored in the MySQL table’s column, we can use MySQL LEFT() function. It will return the number of characters specified as its argument. We need to provide the name of the column, having the particular record from which we want to get starting characters, as its first argument. To demonstrate it we are taking the example of a table named ‘examination_btech’ having the following examination details of students −mysql> Select * from examination_btech; +-----------+----------+--------+ | RollNo | Name | Course | +-----------+----------+--------+ | 201712001 | Rahul ... Read More

149 Views
To get some last number of characters from the data stored in MySQL table’s column, we can use MySQL RIGHT() function. It will return the number of characters specified as it argument. We need to provide the name of the column, having the particular record from which we want to get last characters, as its first argument. To demonstrate it we are taking the example of a table named ‘examination_btech’ having the following examination details of students −mysql> Select * from examination_btech; +-----------+----------+--------+ | RollNo | Name | Course | +-----------+----------+--------+ | 201712001 | Rahul | ... Read More

599 Views
With the help of SHOW CREATE PROCEDURE statement, we can see the source code of a stored procedure. To make it understand we are using the stored procedure named allrecords() in the query as follows −mysql> Show Create Procedure allrecords\G *************************** 1. row *************************** Procedure: allrecords sql_mode:ONLY_FULL_GROUP_BY, STRICT_TRANS_TABLES, NO_ZERO_IN_DATE, NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION Create Procedure: CREATE DEFINERb=`root`@`localhost` PROCEDURE `allrecords`() BEGIN Select * from Student_info; END character_set_client: cp850 collation_connection: cp850_general_ci Database Collation: latin1_swedish_ci 1 row in set (0.00 sec)Read More

131 Views
We can use mysql.proc to see the list, along with complete information, of stored procedures in a particular MySQL database by the following query −mysql> Select * from mysql.proc where db = 'query' AND type = 'PROCEDURE' \G *************************** 1. row *************************** db: query name: allrecords type: PROCEDURE specific_name: allrecords language: SQL sql_data_access: CONTAINS_SQL is_deterministic: NO security_type: DEFINER ... Read More

130 Views
We can see only the list of stored procedures in a particular MySQL database by the following query −mysql> SHOW PROCEDURE STATUS WHERE db = 'query'\G *************************** 1. row *************************** Db: query Name: allrecords Type: PROCEDURE Definer: root@localhost Modified: 2017-11-11 09:56:11 Created: 2017-11-11 09:56:11 Security_type: DEFINER Comment: character_set_client: cp850 collation_connection: cp850_general_ci Database Collation: latin1_swedish_ci 1 row in set (0.01 sec)

1K+ Views
Suppose if we are calculating the sum of the values of a column which also have NULL values then MySQL SUM() function ignores the NULL values and does the sum of the rest of the values. To understand it, consider the following example of table ‘employee’, having following details − mysql> Select * from Employee; +----+--------+--------+ | ID | Name | Salary | +----+--------+--------+ | 1 | Gaurav | 50000 | | 2 | Rahul | 20000 | | 3 | Advik | 25000 | | 4 | ... Read More