SQL INNER JOIN OR JOIN

When you want to combine two or more tables in SQL then commonly you use SQL JOIN or SQL INNER JOIN.

For example EMPLOYEE Table has

EMP_IDEMP_NAMEHIRE_DATESALARYDEPT_ID
1Roger Fed2001-05-0150004
2Djoker Nova2002-07-1565001
3Stef Graph2005-10-1880005
4Mart Hingis2007-01-0372003
5Andre Duplesi2008-06-245600null

DEPARTMENT Table has

DEPT_IDDEPT_NAME
1French Open
2Wimbledon
3US Open
4Aus Open
5Olympics Games

Now lets try a SELECT JOIN statement

SELECT DEPT_ID, DEPT_NAME, EMP_NAME, SALARY   

   FROM  EMPLOYEE e, DEPARTMENT d

   WHERE e.DEPT_ID =d.DEPT_ID;  

The Output will look like this:

DEPT_IDDEPT_NAMEEMP_NAMESALARY
4Aus OpenRoger Fed5000
1French OpenDjoker Nova6500
5Olympics GamesStef Graph8000
3US OpenMart Hingis7200

INNER JOIN select all records from both tables as long as there is a match between the columns in these 2 tables. If no match in DEPARTMENT table found w.r.t EMPLOYEE table then those records of DEPARTMENT table wont be shown.

Learn more : SQL Tutorial , SQL Interview Questions