(iii) SELECT CNAME, AGE, PAY FROM CLUB WHERE
GENDER = "MALE" AND PAY BETWEEN 1000 AND 1200;
Answer by student
The output of the SQL query is
Detailed answer by teachoo
- The given SQL query is a SELECT statement that retrieves data from the table CLUB .
- The CNAME , AGE , and PAY columns are specified in the SELECT clause, which means that only these three columns will be displayed in the result set.
- The WHERE clause is used to filter the rows that match certain conditions. In this case, the conditions are:
- GENDER = “MALE” , which means that the gender (GENDER) should be equal to ‘MALE’. This condition will exclude the rows that have a different gender value.
- PAY BETWEEN 1000 AND 1200 , which means that the pay (PAY) should be in the range of 1000 to 1200, inclusive. This condition will exclude the rows that have a pay value outside this range.
- The AND operator is used to combine the two conditions, which means that both of them should be true for a row to be selected. This operator will narrow down the result set by eliminating the rows that do not satisfy both conditions.
- The result of the query is a table with three columns ( CNAME , AGE , and PAY ) and two rows that match the conditions. To find these rows, we can look at the table and compare each row with the conditions. They are:
- The row with CID=1622, CNAME=AMRIT, AGE=28, GENDER=MALE, SPORTS=KARATE, PAY=1000, DOAPP=2007-09-05. This row satisfies both conditions, since GENDER is ‘MALE’ and PAY is 1000. Therefore, this row is selected and its CNAME, AGE, and PAY values are displayed in the result set.
- The row with CID=2321, CNAME=VIRAT, AGE=35, GENDER=MALE, SPORTS=CRICKET, PAY=1050, DOAPP=2005-04-30. This row also satisfies both conditions, since GENDER is ‘MALE’ and PAY is 1050. Therefore, this row is also selected and its CNAME, AGE, and PAY values are displayed in the result set.
- The other rows do not satisfy both conditions, so they are not selected and not displayed in the result set.
So, the final output of the query is: