Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

MySQL Interview Questions and Answers

Test your skills through the online practice test: MySQL Quiz Online Practice Test

Ques 101. How To Use IN Conditions?

An IN condition is single value again a list of values. It returns TRUE, if the specified value is in the list. Otherwise, it returns FALSE. Some examples are given in the tutorial exercise below:

SELECT 3 IN (1,2,3,4,5) FROM DUAL;
1

SELECT 3 NOT IN (1,2,3,4,5) FROM DUAL;
0

SELECT 'Y' IN ('F','Y','I') FROM DUAL;
1

Is it helpful? Add Comment View Comments
 

Ques 102. How To Create a New View in MySQL?

You can create a new view based on one or more existing tables by using the "CREATE VIEW viewName AS selectStatement" statement as shown in the following script:

mysql> CREATE TABLE comment (faqID INTEGER,
message VARCHAR(256));
Query OK, 0 rows affected (0.45 sec)

mysql> INSERT INTO comment VALUES (1, 'I like it');
Query OK, 1 row affected (0.00 sec)

mysql> CREATE VIEW faqComment AS SELECT f.id, f.title,
f.description, c.message FROM faq f, comment c
WHERE f.id = c.faqID;
Query OK, 0 rows affected (0.06 sec)

Is it helpful? Add Comment View Comments
 

Ques 103. How To Use LIKE Conditions?

A LIKE condition is also called pattern patch. There are 3 main rules on using LIKE condition:

* '_' is used in the pattern to match any one character.
* '%' is used in the pattern to match any zero or more characters.
* ESCAPE clause is used to provide the escape character in the pattern.

The following tutorial exercise provides you some good pattern matching examples:

SELECT 'WithoutBook.com' LIKE '%center%' FROM DUAL;
1

SELECT 'WithoutBook.com' LIKE '%CENTER%' FROM DUAL;
1
-- Case insensitive by default

SELECT 'WithoutBook.com' LIKE '%CENTER_com' FROM DUAL;
1

Is it helpful? Add Comment View Comments
 

Ques 104. How To Drop an Existing View in MySQL?

If you have an existing view, and you don't want it anymore, you can delete it by using the "DROP VIEW viewName" statement as shown in the following script:

mysql> DROP VIEW faqComment;
Query OK, 0 rows affected (0.00 sec)

Is it helpful? Add Comment View Comments
 

Ques 105. How To Use Regular Expression in Pattern Match Conditions?

If you have a pattern that is too complex for LIKE to handle, you can use the regular expression pattern condition: REGEXP. The following tutorial exercise provides you some good examples:

SELECT 'WithoutBook.com' REGEXP '.*ggl.*' FROM DUAL;
1

SELECT 'WithoutBook.com' REGEXP '.*com$' FROM DUAL;
1

SELECT 'WithoutBook.com' REGEXP '^F.*' FROM DUAL;
1

Is it helpful? Add Comment View Comments
 

Most helpful rated by users:

©2024 WithoutBook