Computer Science, asked by kritikayadav190305, 6 months ago

Write the commands in MySQL for the following : [5]
1. To list name, department and date of hiring of all the teachers in ascending order of Hiredate.
2. To display name and department of those teachers whose name starts with S.
3. To list name and department of TGT female teachers.
4. To display name and salary of male teachers whose salary is more than 25000.
5. To display teachers who belong to Art, Math and Science department.
6. To display details of teachers whose name is 10 or 11 characters long.
7. To display names of those teachers who are hired in the year 1980.
8. To display details of those teachers whose salary is not in the range of 27000 to 30000.
9. To display the different departments of teacher table.
10. To display name and department of all teachers with a hyphen (Tanya Nanda – Social Studies)
between them.

Attachments:

Answers

Answered by poojan
9

Queries:

1. To list name, department and date of hiring of all the teachers in ascending order of Hiredate.

SELECT Name, Department, Hiredate

FROM Teachers

ORDER BY Hiredate;

2. To display name and department of those teachers whose name starts with S.

SELECT Name, Department

FROM Teachers

WHERE Name LIKE 'S%';

3. To list name and department of TGT female teachers.

SELECT Name, Department

FROM Teachers

WHERE (Grade = 'TGT') AND (Gender = 'F');

4. To display name and salary of male teachers whose salary is more than 25000.

SELECT Name, Salary

FROM Teachers

WHERE (Gender = 'M')

    AND (Salary > 25000);

5. To display teachers who belong to Art, Math and Science department.

SELECT Name

FROM Teachers

WHERE (Department = 'Art')

      OR (Department = 'Math')

      OR (Department = 'Science');

6. To display details of teachers whose name is 10 or 11 characters long.

SELECT *

FROM Teachers

WHERE (LENGTH(Name) = 10)

       OR (LENGTH(Name) = 11);

7. To display names of those teachers who are hired in the year 1980.

SELECT Name

FROM Teachers

WHERE YEAR(Hiredate) LIKE '1980%';

8. To display details of those teachers whose salary is not in the range of 27000 to 30000.

SELECT *

FROM Teachers

WHERE Salary NOT BETWEEN 27000 AND 30000;

9. To display the different departments of teacher table.

SELECT DISTINCT(Department)

FROM Teachers;

10. To display name and department of all teachers with a hyphen (Tanya Nanda – Social Studies) between them.

SELECT CON CAT(Name, ' - ', Department)

FROM Teachers;

The last one, con cat(), from MySQL 4.0 version. And please remove space between 'con' and 'cat' while writing the query in the compiler.

Learn more:

1. Write a query to create a table with the following structure table product field data type P name whatcha description watches price decimal.

https://brainly.in/question/15451124

2. What are the maximum and the minimum number of rows returned by the R1 right outer join R2?

https://brainly.in/question/21195376

Similar questions