- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 4378 Articles for MySQL
76 Views
With the help of CHARSET() function, we can check which string is returned by MySQL CHAR() function. Following result set will demonstrate it − mysql> Select CHARSET(CHAR(85)); +-------------------+ | CHARSET(CHAR(85)) | +-------------------+ | binary | +-------------------+ 1 row in set (0.00 sec)
72 Views
MySQL converts the arguments of CHAR() function which is greater than 255 to multiple result bytes. For example, CHAR(260) is equivalent to CHAR(0,1,0,4). It can be more clear with the help of following statements −mysql> Select HEX(CHAR(256)),HEX(CHAR(1,0)); +----------------+----------------+ | HEX(CHAR(256)) | HEX(CHAR(1,0)) | +----------------+----------------+ | 0100 | 0100 | +----------------+----------------+ 1 row in set (0.00 sec)The above result set shows that CHAR(256) is equivalent to CHAR(1,0).
722 Views
As we know that MySQL provides us loop statements that allow us to execute a block of SQL code repeatedly based on a condition. A REPEAT loop statement is one of such kind of loop statement. Its syntax is as follows −REPEAT statements; UNTIL expression END REPEATFirst of all, MySQL executes the statements, and then it evaluates the expression. If the expression evaluates to FALSE, MySQL executes the statements repeatedly until the expression evaluates to TRUE. The REPEAT loop checks the expression after the statements execute, that is why it is also called a post-test loop.To demonstrate the use of a ... Read More
2K+ Views
As we know that MySQL provides us loop statements that allow us to execute a block of SQL code repeatedly based on a condition. WHILE loop statement is one of such kind of loop statements. Its syntax is as follows −WHILE expression DO statements END WHILEActually, the WHILE loop checks the expression at the starting of every iteration. If the expression evaluates to true, MySQL will execute statements between WHILE and END WHILE until the expression evaluates to false. The WHILE loop checks the expression before the statements execute, that is why it is also called the pretest loop.To demonstrate ... Read More
61 Views
MySQL CHAR() function will ignore NULL if it is provided as an argument to it. To understand it, consider the following examples −mysql> Select CHAR(65,66,67,NULL); +---------------------+ | CHAR(65,66,67,NULL) | +---------------------+ | ABC | +---------------------+ 1 row in set (0.00 sec) mysql> Select CHAR(NULL,66,67,NULL); +-----------------------+ | CHAR(NULL,66,67,NULL) | +-----------------------+ | BC | +-----------------------+ 1 row in set (0.00 sec)In both the examples above, CHAR() function ignores the NULL and converts the numeric value into character value.
1K+ Views
Actually, the CASE statement has the functionality of an IF-THEN-ELSE statement. It has the following syntax −CASE WHEN condition_1 THEN {...statements to execute when condition_1 is TRUE...} [ WHEN condition_2 THEN {...statements to execute when condition_2 is TRUE...} ] [ WHEN condition_n THEN {...statements to execute when condition_n is TRUE...} ] [ ELSE {...statements to execute when all conditions were FALSE...} ] END CASE;The CASE statement will execute the ELSE clause if none of the WHEN clauses were executed.To demonstrate the use of CASE statement within MySQL stored procedure, we are creating the following stored procedure which ... Read More
14K+ Views
MySQL IF ELSE statement implements a basic conditional construct when the expression evaluates to false. Its syntax is as follows −IF expression THEN statements; ELSE else-statements; END IF;The statements must end with a semicolon.To demonstrate the use of IF ELSE statement within MySQL stored procedure, we are creating the following stored procedure which is based on the values, as shown below, of the table named ‘student_info’ −mysql> Select * from student_info; +------+---------+------------+------------+ | id | Name | Address | Subject | +------+---------+------------+------------+ | 101 | YashPal | Amritsar | History | | 105 | ... Read More
10K+ Views
MySQL IF ELSEIF ELSE execute the statements based on multiple expressions Its syntax is as follows −IF expression THEN statements; ELSEIF elseif-expression THEN elseif-statements; … … … … ELSE else-statements; END IF;The statements must end with a semicolon.To demonstrate the use of IF ELSEIF ELSE statement within MySQL stored procedure, we are creating the following stored procedure which is based on the values, as shown below, of the table named ‘student_info’ −mysql> Select * from student_info; +------+---------+------------+------------+ | id | Name | Address | Subject | +------+---------+------------+------------+ | 101 | YashPal | Amritsar ... Read More
465 Views
The IGNORE_SPACE SQL mode can be used to modify how the parser treats function names that are whitespace-sensitive. Following are the cases in which we can use IGNORE_SPACE SQL mode −Case-1 − When IGNORE_SPACE SQL mode is disabledAfter disabling the IGNORE_SPACE SQL mode, the parser interprets the name as a function call when there is no whitespace between the name and the following parenthesis. This also occurs when the function name is used in a non-expression context. It can be understood from the following query −mysql> Create table SUM(Id Int); ERROR 1064 (42000): You have an error in your SQL ... Read More
72 Views
The default rules used by the parser for parsing names of built-in-function can be changed by enabling IGNORE_SPACE SQL mode. When we enable this mode, the parser relaxes the requirement that there be no whitespace between the function name and the following parenthesis. For example, after enabling IGNORE_SPACE SQL mode both of the following function calls are legal −Select SUM(Salary) from employee; Select SUM (Salary) from employee;But, in this case, the parser treats the function name as reserved words. It means that a space following the names no longer represents as an identifier.