Skip to main content

Posts

Showing posts with the label SQL

SQL query to fetch employees based on a given department name?

  To fetch employees based on a given department name using SQL, you can use a SQL query with a JOIN clause and a WHERE condition to filter by the department name. Assuming you have two tables, Employee and Department , with appropriate columns. Department: id name 1 HR 2 Java Employee: id name department_id 101 Gangu 1 103 Naidu 2 SQL query to achieve this: sql SELECT e.name AS employee_name FROM Employee e JOIN Department d ON e.departmentId = d.id WHERE d.name = 'Java' ; In this SQL query: We select the name of the employees from the Employee table and alias it as employee_name . We perform an INNER JOIN between the Employee and Department tables based on the departmentId column in the Employee table and the id column in the Department table. This links employees to their respective departments. We use a WHERE condition to filter the results. In this case, we filter employees whose department's name matches 'Java'. You can replace 'Java...

Popular posts from this blog

Subscribe to get new posts

Name

Email *

Message *