I got busted with some easy mySql questions; anyway I expect this heck again and again. So I buried my self in google to find out the answers:

and here we go!

1. What is the difference between primary key and unique key?

Primary Key:

This is an index that cannot be NULL, Primary Keys are used in building relationships between tables in a database. (an index is automatically created on the primary key). The difference between primary and ordinary keys is that there can be multiple keys, but only one primary key.


Unique Key:

Unique and Index are same, the difference is, in Unique, duplicate are not allowed in any circumstances and that is enforced by database server.


2. How can you get rows in between of two keys ?

It can be done by using sql between.


Syntax:
********** SELECT <fields> FROM <table> WHERE <key_field> BETWEEN <key1> AND <key2>


Example : select f_name, l_name, age from employee_data where age BETWEEN 32 AND 40;

Followers

FeedCount

Latest Posts

thecoderinc

Subscribe Now