1.

Shewani has recently started working in MySQL. Help her in understanding the difference between the following :(i)  Where and having clause(ii)  Count(column_name) and count(*)

Answer»

(i)  Where clause is used to show data set for a table based on a condition and having clause is used to put condition on the result set that comes after using Group by clause.

(ii)  COUNT(*) returns the number of items in a group, including NULL values and duplicates. COUNT(expression) evaluates expression for each row in a group and returns the number of non null values.

Candidate Key – A Candidate Key can be any column or a combination of columns that can qualify as unique key in database. There can be multiple Candidate Keys in one table. Each Candidate Key can qualify as Primary Key.

Primary Key – A Primary Key is a column or a combination of columns that uniquely identify a record. Only one Candidate Key can be Primary Key. 

A table can have multiple Candidate Keys that are unique as single column or combined multiple columns to the table. They are all candidates for Primary Key.



Discussion

No Comment Found

Related InterviewSolutions