Found 4381 Articles for MySQL

In MySQL, how can we convert a value from one number system to the value in another number system?

Moumita
Updated on 03-Feb-2020 06:11:19

137 Views

With the help of MySQL CONV() function, a value from one number system can be converted to the other number system.SyntaxCONV(N, from_base, to_base)Here, ‘N’ is the number which is to be converted, ‘from_base’ is the current base of that number and ‘to_base’ is the base in which that number has to be converted. ‘N’ is interpreted as an integer but it may be specified as integer or a string.Examplemysql> Select CONV('10', 10, 2) AS 'DECIMAL TO BINARY'; +-------------------+ | DECIMAL TO BINARY | +-------------------+ | 1010              | +-------------------+ 1 row in set (0.00 sec)In ... Read More

When MySQL LOCATE() function returns NULL as the output?

Kumar Varma
Updated on 03-Feb-2020 06:11:55

320 Views

It will return NULL as the output when the value of either first argument i.e. substring or the value of second argument i.e. substring is NULL. Example below will demonstrate it −Examplemysql> Select LOCATE(NULL,'Ram is a good boy')As Result; +--------+ | Result | +--------+ | NULL   | +--------+ 1 row in set (0.00 sec) mysql> Select LOCATE('Ram',NULL)As Result; +--------+ | Result | +--------+ | NULL   | +--------+ 1 row in set (0.00 sec)

How can I manage the start position of searching in MySQL LOCATE() function?

Chandu yadav
Updated on 03-Feb-2020 06:12:45

145 Views

As we know that by default searching in LOCATE() function starts from beginning. We can manage the start position by giving an argument to specify the position from which we want to start the search in string. Following example will demonstrate it −Examplemysql> Select LOCATE('good','Ram is a good boy. Is Ram a good boy?',11)As Result; +--------+ | Result | +--------+ |     29 | +--------+ 1 row in set (0.00 sec)In the above example, we have given the value 11 as the argument for position. It means that MySQL will start searching from 11th position.

What is the difference between MySQL LOCATE() and FIND_IN_SET() functions?

Monica Mona
Updated on 03-Feb-2020 06:14:05

600 Views

As we know, both the functions are used to search a string from the arguments provided in them but there are some significant differences between them as followsFIND_IN_SET() function uses the string list that is itself a string containing the substring separated by commas. Whereas, LOCATE() function contains a string from which it will find the position of the first occurrence of the substring if present. In LOCATE() function we can manage the starting point of the search by providing an optional argument for a position. Whereas, for FIND_IN_SET() function MySQL do not provide such kind of flexibility and the search ... Read More

What happens if the substring is there for more than one time in the string given as the arguments of LOCATE() function?

Rama Giri
Updated on 03-Feb-2020 06:15:53

103 Views

In case if the substring is there for more than one time in the string then MySQL LOCATE() function will return the position of the first occurrence of the substring.Examplemysql> Select LOCATE('good','Ram is a good boy. Is Ram a good boy?')As Result; +--------+ | Result | +--------+ |     10 | +--------+ 1 row in set (0.00 sec)As we can see that the substring ‘good’ is in the string for two times. The first occurrence is at position 10 and another occurrence is at position 29. MySQL returns the position of the first occurrence.

What is the maximum length of each type of identifier in MySQL?

Smita Kapse
Updated on 06-Feb-2020 10:31:07

567 Views

As we know that certain objects within MySQL are known as identifiers. These objects include a database, table, index, column, alias, view, stored procedure, partition, tablespace etc. Identifiers are stored using Unicode (UTF-8). The maximum length of each type of identifier is given in the following table:Sr. No.IdentifierMaximum Length (characters)1Database642Table643Column644Index645Constraint646Stored Procedure or Function647Trigger648View649Event6410Tablespace6411Log File Group6412Alias25613Compound Statement Label16

How can we use the MySQL reserved words as an identifier?

Giri Raju
Updated on 03-Feb-2020 06:17:07

594 Views

We must have to use quotes with reserved words to use them as an identifier. The quotes can be single or double depends upon ANSI_QUOTES SQL mode.If this mode is disabled then the identifier quote character is the backtick (“`”). Consider the following example in which we created a table named ‘select’ −mysql> create table `select`(id int); Query OK, 0 rows affected (0.19 sec)If this mode is enabled then we can use backtick (“`”) and double quotes (“”) both as identifier quote character. Consider the following example in which we created a table named ‘trigger’ −mysql> Create table "trigger" (id ... Read More

How Can we permanently define user-defined variable for a client in MySQL?

Anvi Jain
Updated on 30-Jul-2019 22:30:21

310 Views

In MySQL, it is not possible that a client can hold user variable permanently. It is because all the variables for a given client connection are automatically freed when that client exits.

In MySQL, why a client cannot use a user-defined variable defined by another client?

Sreemaha
Updated on 30-Jul-2019 22:30:21

281 Views

In MySQL, a user-defined variable defined by one client cannot be seen or used by another client because user-defined variables are connection-specific. It means that all variables for a given client connection are automatically freed when that client exits

What happens if I will use integer values as arguments of MySQL LOCATE() function?

Manikanth Mani
Updated on 03-Feb-2020 05:54:05

102 Views

MySQL allows us to use integer values as the arguments of the LOCATE() function. We do not need to use quotes. It can be demonstrated with the help of the following example −Examplemysql> Select LOCATE(5,1698235); +-------------------+ | LOCATE(5,1698235) | +-------------------+ |                 7 | +-------------------+ 1 row in set (0.00 sec) mysql> Select LOCATE(56,1698235); +--------------------+ | LOCATE(56,1698235) | +--------------------+ |                  0 | +--------------------+ 1 row in set (0.00 sec) mysql> Select LOCATE(23,1698235); +--------------------+ | LOCATE(23,1698235) | +--------------------+ |                  5 | +--------------------+ 1 row in set (0.00 sec)

Advertisements