
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 4381 Articles for MySQL

165 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

292 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

105 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

92 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

4K+ Views
When designing a database, setting default values for certain fields will improve data integrity. In MySQL, ENUM data type allows you to specify predefined values for a column such as status (complete or incomplete). This article helps you to set a default value for ENUM columns, to ensure that even if the data is missing, a suitable value is automatically assigned. Inserting a default value with ENUM data type We can do this with the help of the DEFAULT attribute of the ENUM data type. The DEFAULT attribute causes an ENUM data type to have a default value when a ... Read More

1K+ Views
MySQL stores ENUM values internally as integer keys (index numbers) to reference ENUM members. The main reason for not storing the integer values in the ENUM column is that it is very obvious that MySQL ends up referencing the index instead of the value and vice-versa. These indexes begin at 1, not 0, and map to the order of the values defined during table creation. If a number is inserted directly into an ENUM column, MySQL interprets it as the corresponding index, leading to unexpected behavior. Example Let us create a table named Enmtest ... Read More

122 Views
As we know the 1st argument of ELT() function must be an integer value but when we provide index number which is not an integer the MySQL ELT() function returns NULL with a warning.Examplemysql> select ELT('one','Ram,is,good,boy')As Result; +--------+ | Result | +--------+ | NULL | +--------+ 1 row in set, 1 warning (0.00 sec) mysql> Show Warnings; +---------+------+------------------------------------------+ | Level | Code | Message | +---------+------+------------------------------------------+ | Warning | 1292 | Truncated incorrect INTEGER value: 'one' | +---------+------+------------------------------------------+ 1 row in set (0.00 sec)

155 Views
As we know that enumeration values are associated with index values hence if we will use enumeration values in an expression then all the calculations would be done on index numbers. The following example will clarify it −mysql> Select * from Result; +-----+--------+-------+ | Id | Name | Grade | +-----+--------+-------+ | 100 | Gaurav | GOOD | | 101 | Rahul | POOR | | 102 | Rahul | NULL | | 103 | Mohan | | +-----+--------+-------+ 4 rows in set (0.00 sec) mysql> Select SUM(Grade) from result; +------------+ | SUM(Grade) | +------------+ ... Read More

109 Views
MySQL ELT() function returns NULL as output if the index number provided as argument is higher than the number of strings. Following is an example to make it clearer −Examplemysql> Select ELT(6,'Ram','is','a','good','boy')As Result; +--------+ | Result | +--------+ | NULL | +--------+ 1 row in set (0.00 sec)As we can see that index number is 6 and the list of strings is having only 5 strings. Hence MySQL returns NULL.

1K+ 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 follows −FIND_IN_SET() − function uses the string list that is itself a string containing the substring separated by commas. Whereas, FIELD() function contains list of different strings among which it will find the index number of the string, if present, which is to be searched.FIND_IN_SET() − function returns NULL if any of the argument i.e. either search string or string list is NULL. In contrast, FIELD() function do not returns NULL but returns ... Read More