Wipro MySQL Interview Questions Answers

How Do You Return The A Hundred Books Starting From 25th?

SELECT book_title FROM books LIMIT 25, 100. The first number in LIMIT is the offset, the second is the number.

You Wrote A Search Engine That Should Retrieve 10 Results At A Time, But At The Same Time You'd Like To Know How Many Rows There're Total. How Do You Display That To The User?

SELECT SQL_CALC_FOUND_ROWS page_title FROM web_pages LIMIT 1,10; SELECT FOUND_ROWS(); The second query (not that COUNT() is never used) will tell you how many results there’re total, so you can display a phrase "Found 13,450,600 results, displaying 1-10". Note that FOUND_ROWS does not pay attention to the LIMITs you specified and always returns the total number of rows affected by query.

How Would You Write A Query To Select All Teams That Won Either 2, 4, 6 Or 8 Games?

SELECT team_name FROM teams WHERE team_won IN (2, 4, 6, 8)

How Would You Select All The Users, Whose Phone Number Is Null?

SELECT user_name FROM users WHERE ISNULL(user_phonenumber);

What Does This Query Mean: Select User_name, User_isp From Users Left Join Isps Using (user_id) ?

It’s equivalent to saying SELECT user_name, user_isp FROM users LEFT JOIN isps WHERE users.user_id=isps.user_id

How Do You Find Out Which Auto Increment Was Assigned On The Last Insert?

SELECT LAST_INSERT_ID() will return the last value assigned by the auto_increment function. Note that you don’t have to specify the table name.
Wipro MySQL Most Frequently Asked Latest Interview Questions Answers
Wipro MySQL Most Frequently Asked Latest Interview Questions Answers

What Does -i-am-a-dummy Flag To Do When Starting Mysql?

Makes the MySQL engine refuse UPDATE and DELETE commands where the WHERE clause is not present.

On Executing The Delete Statement I Keep Getting The Error About Foreign Key Constraint Failing. What Do I Do?

What it means is that so of the data that you’re trying to delete is still alive in another table. Like if you have a table for universities and a table for students, which contains the ID of the university they go to, running a delete on a university table will fail if the students table still contains people enrolled at that university. Proper way to do it would be to delete the offending data first, and then delete the university in Question. Quick way would involve running SET foreign_key_checks=0 before the DELETE command, and setting the parameter back to 1 after the DELETE is done. If your foreign key was formulated with ON DELETE CASCADE, the data in dependent tables will be removed automatically.

When Would You Use Order By In Delete Statement?

When you’re not deleting by row ID. Such as in DELETE FROM techpreparation_com_Questions ORDER BY timestamp LIMIT 1.

How Can You See All Indexes Defined For A Table?

SHOW INDEX FROM techpreparation_Questions;

How Would You Change A Column From Varchar(10) To Varchar(50)?

ALTER TABLE techpreparation_Questions CHANGE techpreparation_content techpreparation_CONTENT VARCHAR(50).

How Would You Delete A Column?

ALTER TABLE techpreparation_s DROP _user_id.

How Would You Change A Table To Innodb?

ALTER TABLE techpreparation_Questions ENGINE innodb;

When You Create A Table, And Then Run Show Create Table On It, You Occasionally Get Different Results Than What You Typed In. What Does Mysql Modify In Your Newly Created Tables?

1. VARCHARs with length less than 4 become CHARs
2. CHARs with length more than 3 become VARCHARs.
3. NOT NULL gets added to the columns declared as PRIMARY KEYs
4. Default values such as NULL are specified for each column

How Do I Find Out All Databases Starting With 'tech' To Which I Have Access To?

SHOW DATABASES LIKE ‘tech%’;

How Do You Concatenate Strings In Mysql?

CONCAT (string1, string2, string3)

How Do You Get A Portion Of A String?
SELECT SUBSTR(title, 1, 10) from techpreparation_Questions;

What's The Difference Between Char_length And Length?

The first is, naturally, the character count. The second is byte count. For the Latin characters the numbers are the same, but they’re not the same for Unicode and other encodings.

How Do You Convert A String To Utf-8?

SELECT (techpreparation_Question USING utf8);

What Do % And _ Mean Inside Like Statement?

% corresponds to 0 or more characters, _ is exactly one character.

What Does + Mean In Regexp?

At least one character. Appendix G. Regular Expressions from MySQL manual is worth perusing before the interview.

How Do You Get The Month From A Timestamp?

SELECT MONTH(techpreparation_timestamp) from techpreparation_Questions;

How Do You Offload The Time/date Handling To Mysql?

SELECT DATE_FORMAT(techpreparation_timestamp, ‘%Y-%m-%d’) from techpreparation_Questions; A similar TIME_FORMAT function deals with time.

How Do You Add Three Minutes To A Date?

ADDDATE(techpreparation_publication_date, INTERVAL 3 MINUTE)

What's The Difference Between Unix Timestamps And Mysql Timestamps?

Internally Unix timestamps are stored as 32-bit integers, while MySQL timestamps are stored in a similar manner, but represented in readable YYYY-MM-DD HH:MM:SS format.

How Do You Convert Between Unix Timestamps And Mysql Timestamps?

UNIX_TIMESTAMP converts from MySQL timestamp to Unix timestamp, FROM_UNIXTIME converts from Unix timestamp to MySQL timestamp.

Post a Comment

Previous Post Next Post