Get Starting Number of Characters from MySQL Table Column

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

142 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

List Stored Procedures in a MySQL Database

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

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

Customize MySQL SUM Function Output to 0 Instead of NULL

Arjun Thakur
Updated on 22-Jun-2020 05:20:30

307 Views

As we know that the SUM() function returns NULL if there is no matching row but sometimes we want it to return zero instead of NULL. For this purpose, we can use the MySQL COALESCE() function which accepts two arguments and returns the second argument if the first argument is NULL, otherwise, it returns the first argument. To understand the above concept, consider an ‘employee_tbl’ table, which is having the following records −mysql> SELECT * FROM employee_tbl; +------+------+------------+--------------------+ | id   | name | work_date  | daily_typing_pages | +------+------+------------+--------------------+ | 1    | John | 2007-01-24 |       ... Read More

Advantages and Disadvantages of Using MySQL Stored Procedures

Nitya Raut
Updated on 22-Jun-2020 05:19:43

3K+ Views

There are numerous advantages and disadvantages of using MySQL stored procedures which are as follows −MySQL Stored Procedure AdvantagesFollowings are the advantages of using MySQL Stored Procedures −Increasing the performance of applications − As we know that after creating the stored procedure it is compiled and stored in the database. But MySQL implements stored procedures slightly different which helps in increasing the performance of the applications. MySQL stored procedures are compiled on demand. After compiling a stored procedure, MySQL puts it into a cache. And MySQL maintains its own stored procedure cache for every single connection. If an application uses ... Read More

View Names and Types of Stored Routines in MySQL Database

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

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

Get Last Number of Characters from MySQL Table Column

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

159 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

List Stored Procedures in a MySQL Database

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

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

MySQL COUNT Function with NULL Values

Jai Janardhan
Updated on 22-Jun-2020 05:13:36

212 Views

When we use MySQL COUNT() function to count the values stored in a column which also stored some NULL values then MySQL ignores the NULL and returns the result for only non-NULL values. To understand it, we are using the data, as follows, from table ‘Employee’ −mysql> Select * from Employee; +----+--------+--------+ | ID | Name   | Salary | +----+--------+--------+ | 1  | Gaurav | 50000  | | 2  | Rahul  | 20000  | | 3  | Advik  | 25000  | | 4  | Aarav  | 65000  | | 5  | Ram    | 20000  | | 6  | ... Read More

Get Only Table Names from MySQL Database

Sreemaha
Updated on 22-Jun-2020 05:12:48

158 Views

With the help of SHOW TABLES command, we can get only the name having no other information about the tables. For example, we can see the list of tables in a database named tutorial as follows −mysql> show tables; +--------------------+ | Tables_in_tutorial | +--------------------+ | student            | +--------------------+ 1 row in set (0.00 sec)

MySQL SUM Function for Dissimilar Column Values

Manikanth Mani
Updated on 22-Jun-2020 05:12:02

165 Views

For calculating the sum of only dissimilar values of the column we can use ‘DISTINCT’ keyword along with the name of the column. To understand SUM() function for dissimilar values, consider an ‘employee_tbl’ table, which is having the following records −mysql> SELECT * FROM employee_tbl; +------+------+------------+--------------------+ | id   | name | work_date  | daily_typing_pages | +------+------+------------+--------------------+ | 1    | John | 2007-01-24 | 250                | | 2    | Ram  | 2007-05-27 | 220                | | 3    | Jack | 2007-05-06 | 170 ... Read More

Advertisements