Skip to content
Advertisement

How to join two tables to get combined result

I am trying to write a query, where I am retrieving employee data, fname, salary and unit no., where fname is ‘Khalid’ and his department name should be either ‘IT’ or ‘Development’.

I am writing the query as

Both table have relationship based on Department number.

For Example:

Employee Table:

Department Table:

Now the two table is in a relationship. My query is not using Dno and Dnumber to connect them and finding the accurate result. Do I need to use JOIN here? and how I know which is left table and which is right table?

Advertisement

Answer

You can join and filter:

Alternatively, you can also use a correlated subquery for filtering, if you don’t need to display the department name:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement