Found 4219 Articles for MySQLi

What are the different modes of parameters used by MySQL stored procedure?

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

1K+ 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

88 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

65 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

65 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

365 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

78 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

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

mkotla
Updated on 22-Jun-2020 05:14:31

84 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)

How MySQL SUM() function evaluates if the column having NULL values too?

George John
Updated on 30-Jul-2019 22:30:21

901 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

How can we see only the list of stored procedures in a particular MySQL database?

Giri Raju
Updated on 22-Jun-2020 05:21:03

100 Views

We can see only the list of stored procedures in a particular MySQL database by the following query −mysql> SELECT ROUTINE_TYPE, ROUTINE_NAME FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA = 'query'AND ROUTINE_TYPE = 'PROCEDURE'// +--------------+------------------------+ | ROUTINE_TYPE | ROUTINE_NAME           | +--------------+------------------------+ | PROCEDURE    | allrecords             | +--------------+------------------------+ 1 row in set (0.05 sec)

How can we see only name and types of the stored routines in a particular MySQL database?

V Jyothi
Updated on 22-Jun-2020 05:16:12

78 Views

We can write the following query to see only the name and types of procedures in a particular MySQL database. To make it understand we are using the database named ‘query’ −mysql> Select Name, Type from mysql.proc where db = 'query'; +------------+-----------+ | Name       | Type      | +------------+-----------+ | allrecords | PROCEDURE | | Hello      | FUNCTION  | +------------+-----------+ 2 rows in set (0.18 sec)

Advertisements