Monica Mona has Published 112 Answers

What MySQL MAKE_SET() function returns if the value of the bit is 1 and the first string is NULL?

Monica Mona
Published on 21-Feb-2018 11:20:48
MySQL MAKE_SET() function returns nothing if the value of the bit is 1 and the first string is NULL. Following example will exhibit this concept −Examplemysql> Select MAKE_SET(1, NULL, 'A', 'B'); +---------------------------+ | MAKE_SET(1, NULL, 'A', 'B') | +---------------------------+ |                     ... Read More

How can I get the output based on comparison done with column’s name using MySQL IN() function?

Monica Mona
Published on 21-Feb-2018 09:49:59
In this scenario, we need to use the name of the column as ‘Expression’ which will then be compared with the values in the list. If a column has value/s matched within the list,  the output would be produced. For understanding it, consider the example from employee table having the following data −mysql> ... Read More

How can we fetch a MySQL SET column as a list of integer offset?

Monica Mona
Published on 21-Feb-2018 09:16:03
We can fetch the MySQL SET column values as a list of integer offset with the help of the MAKE_SET() function. To make it understand, we are creating a table named ‘set_testing’ as follows −mysql> Create table set_testing( id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, table SET('ABC', 'ABD', 'GHF') ... Read More

What are the default rules used by the parser for parsing names of built-in functions?

Monica Mona
Published on 21-Feb-2018 08:09:14
Actually, when a parser encounters a word that is the name of a built-in function, it must determine whether the name represents a function call or is instead a non-expression reference to an identifier such as a table or column name. consider the following queries −1. Select sum(salary) from employee; ... Read More

How can we extract the Year and Month from a date in MySQL?

Monica Mona
Published on 21-Feb-2018 06:55:08
It can be done with the following three ways in MySQLBy using EXTRACT() function For extracting YEAR and MONTH collectively then we can use the EXTRACT function. We need to provide the YEAR_MONTH as an argument for this function. To understand it, consider the following function using the data from table ... Read More

How can I use MySQL IF() function within SELECT statement?

Monica Mona
Published on 21-Feb-2018 05:37:51
It is quite possible to use MySQL IF() function within SELECT statement by providing the name of the column along with a condition as the first argument of IF() function. To understand it, consider the following data from table ‘Students’.mysql> Select * from Students; +----+-----------+-----------+----------+----------------+ | id | Name   ... Read More

What is the use of MySQL UNHEX() function?

Monica Mona
Published on 20-Feb-2018 13:14:56
As its name suggests, it is the opposite of HEX() function. Basically, UNHEX() function converts the hexadecimal number into the byte represented by the number. The value returned by it would be a binary string.SyntaxUNHEX(str)Here, str is a string which is to be converted into the byte represented by the ... Read More

How can we reverse a MySQL string connected by the dash?

Monica Mona
Published on 20-Feb-2018 11:35:31
MySQL has function name REVERSE() with the help of which we can reverse the string. But suppose if we want to reverse the string connected by dash then by using REVERSE() function will not give appropriate result as shown in the following example:mysql> Select REVERSE('AB-CD-EF'); +---------------------+ | REVERSE('AB-CD-EF') | +---------------------+ ... Read More

What are the similarities and differences between MySQL ORD() and ASCII() functions?

Monica Mona
Published on 20-Feb-2018 10:17:26
MySQL ORD() function returns the code for the leftmost character if that character is a multi-byte i.e. sequence of one or more bytes, with the help of the following formula(1st bytecode) + (2nd bytecode * 256) + (3rd bytecode * 256^2)On the other hand, ASCII() function returns the ASCII value ... Read More

In MySQL, how to remove the specific prefix from entire column’s value and update them?

Monica Mona
Published on 20-Feb-2018 09:16:10
It can be done by applying TRIM() function on the column along with MySQL UPDATE statement. The example below will make it more clear.ExampleSuppose, we have a table ‘Employee’ which have the prefix ‘Dept.’ with all the values of Column ‘Department’ as follows −mysql> Select * from Employee; +------+----------------+------------+----------------------+ | ... Read More
Advertisements