Found 4381 Articles for MySQL

How can I create MySQL stored procedure with OUT parameter?

vanithasree
Updated on 22-Jun-2020 05:43:29

5K+ 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 ... Read More

How can we find the most recent and most oldest date from a table with the help of 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

How MySQL evaluates when I use a conditional expression within SUM() function?

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

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

How can I create MySQL stored procedure with IN parameter?

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

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

What are the different modes of parameters used by 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

How MySQL evaluates if I will use an expression within SUM() function?

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

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

How can we get some starting number of characters from the data stored in a MySQL table’s column?

Moumita
Updated on 22-Jun-2020 05:22:02

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

How can we get some last number of characters from the data stored in a MySQL table’s column?

Lakshmi Srinivas
Updated on 22-Jun-2020 05:15:20

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

How can we see the source code of a particular MySQL stored procedure?

Anvi Jain
Updated on 22-Jun-2020 05:31:49

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

How can we see the list, along with complete information, of stored procedures in a particular MySQL database?

Sravani S
Updated on 22-Jun-2020 05:32:26

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

Advertisements