Tuesday 10 February 2015

Basic MySQL Interview Questions for Database (Page 4)

Below are some important MySQL interview questions which are asked in most MNC company interviews for beginners or professionals.

16. How To Concatenate Two Character Strings?
If you want concatenate multiple character strings into one, you need to use the CONCAT() function. Here are some good examples:
SELECT CONCAT(’Welcome’,’ to’) FROM DUAL;
Welcome to
SELECT CONCAT(ggl’,’center’,’.com’) FROM DUAL;
GlobalGuideLi ne.com

17. How To Enter Characters as HEX Numbers?
If you want to enter characters as HEX numbers, you can quote HEX numbers with single quotes and a prefix of (X), or just prefix HEX numbers with (Ox). A HEX number string will be automatically converted into a character string, if the expression context is a string. Here are some good examples:
SELECT X313233’ FROM DUAL;
123
SELECT 0x414243 FROM DUAL;
ABC
SELECT Ox46594963656E7465722E636F6D FROM DUAL;
GlobalGuideLi ne.com

18. How To Enter Boolean Values in SQL Statements?
If you want to enter Boolean values in SQL statements, you use (TRUE), (FALSE), (true), or (false). Here are some good examples:
SELECT TRUE, true, FALSE, false FROM DUAL;

19. How To Convert Numeric Values to Character Strings?
You can convert numeric values to character strings by using the CAST(value AS CHAR) function as shown in the following examples:
SELECT CAST(4123.45700 AS CHAR) FROM DUAL;
4123.45700
--
20. How to get rid of the last 2 0’s?
SELECT CAST(4.12345700E+3 AS CHAR) FROM DUAL;
4123.457
SELECT CAST(1/3 AS CHAR);
0.3333
More Questions & Answers :-

No comments:

Post a Comment