MySql Interview Questions and Answers – Part 2

11 How to returns the columns and column information pertaining to the designated table
mysql> show columns from tablename;

12 How to Show certain selected rows with the value “pcds”
mysql> SELECT * FROM tablename WHERE fieldname = “pcds”;

13 How will Show all records containing the name “sonia” AND the phone number ‘9876543210’
mysql> SELECT * FROM tablename WHERE name = “sonia” AND phone_number = ‘9876543210’;

14 How you will Show all records not containing the name “sonia” AND the phone number ‘9876543210’ order by the phone_number field.
mysql> SELECT * FROM tablename WHERE name != “sonia” AND phone_number = ‘9876543210’ order by phone_number;

15 How to Show all records starting with the letters ‘sonia’ AND the phone number ‘9876543210’
mysql> SELECT * FROM tablename WHERE name like “sonia%” AND phone_number = ‘9876543210’;

16 How to show all records starting with the letters ‘sonia’ AND the phone number ‘9876543210’ limit to records 1 through 5.
mysql> SELECT * FROM tablename WHERE name like “sonia%” AND phone_number = ‘9876543210’ limit 1,5;

17 How you will Show unique records.
mysql> SELECT DISTINCT columnname FROM tablename;

18 how we will Show selected records sorted in an ascending (asc) or descending (desc)
mysql> SELECT col1,col2 FROM tablename ORDER BY col2 DESC;
mysql> SELECT col1,col2 FROM tablename ORDER BY col2 ASC;

19 how to Return total number of rows.
mysql> SELECT COUNT(*) FROM tablename;

20 How to Join tables on common columns.
mysql> select lookup.illustrationid, lookup.personid,person.birthday from lookup left join person on lookup.personid=person.personid=statement to join birthday in person table with primary illustration id

Sign-up for our email newsletter and get free job alerts, current affairs and GK updates regularly.
Subscribe Here (or)

Leave a Reply

Your email address will not be published. Required fields are marked *


four − = 2

Popup Dialog Box Powered By : XYZScripts.com
  • RSS
  • Facebook
  • Google+
  • Twitter