Found 4219 Articles for MySQLi

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

55 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

359 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

477 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

183 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

124 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

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

How MySQL FIELD() and ELT() functions are complements of each other?

Jai Janardhan
Updated on 20-Jun-2020 09:04:45

95 Views

On the basis of the working of both the functions, we can say that both are the complement of each other. Actually, as we know that FIELD() function, on providing a string as an argument, returns the index number of the string from string list and ELT() function, on providing index number as an argument, returns the string from string list. In the following example, we have applied both the functions on the same string, it would demonstrate the concept −Examplemysql> SELECT ELT(4, 'Ram', 'is', 'good', 'boy')As Result; +--------+ | Result | +--------+ | boy    | +--------+ ... Read More

How can we store a value in user-defined variable?

Nitya Raut
Updated on 20-Jun-2020 09:09:22

183 Views

We can store a value in a user-defined variable in a statement and then refer to it afterward in other statements. Followings are the ways to store a value in user-defined variable −With SET statementwe can store a user-defined variable by issuing a SET statement as follows −SyntaxSET @var_name = expr[, @var_name = expr]…In this @var_name is the variable name which consists of alphanumeric characters from current character set. We can use either = or := assignment operator with SET statement.For example following queries can store the user variables with SET statement −mysql> SET @value = 500; Query OK, 0 ... Read More

What happens with the output of MySQL EXPORT_SET() function if I will skip both 4th and 5th argument i.e. separator and number of bits?

Akshaya Akki
Updated on 20-Jun-2020 09:00:18

54 Views

As we know that the default value of the fifth argument i.e. number of bits is 64, hence if we will not specify any value on fifth argument them MySQL will check the bits up to 64 bits and produce the result. Whereas, on skipping the fourth argument i.e. separator, MySQL will use a comma (, ) as a separator while displaying the output.Examplemysql> SELECT EXPORT_SET(8, 'Y', 'N')\G *************************** 1. row *************************** EXPORT_SET(8, 'Y', 'N'): N, N, N, Y, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, ... Read More

What happens with the output of MySQL EXPORT_SET() function if I will skip the value of the fifth argument i.e. a number of bits?

Samual Sam
Updated on 20-Jun-2020 09:08:37

47 Views

Actually, the default value of the fifth argument i.e. number of bits is 64, hence if we will not specify any value on fifth argument them MySQL will check the bits up to 64 bits and produce the result. It can be understood from the following example −Examplemysql> SELECT EXPORT_SET(5, 'Y', 'N', ' ')\G *************************** 1. row *************************** EXPORT_SET(5, 'Y', 'N', ' '): Y N Y N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N ... Read More

Advertisements