2

I want to select all the data from the table employee and make an inner join with an other table for example:

SELECT * FROM EMPLOYEE 
INNER JOIN Deparment ON Employee.Id_Department = Deparment.Deparment_Id 
    AND NVL('Mathematics', Deparment.Name);

When I execute that I get an error ORA-00920: Invalid relational operator, I think maybe the nvl() function is the problem here.

Danny
  • 47
  • 11

2 Answers2

2

you need to add a relational operator like =, !=, < after NVL('Mathematics', Deparment.Name)
as an example :

AND NVL(Deparment.Name,'Mathematics')='Physics'

Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55
1

You have not mentioned the second condition in the join statement also NVL() function parameters misplaced. Try this by assuming employee department name as department_name and change the script as per your need

SELECT *
FROM   employee
       inner join deparment
               ON employee.id_department = deparment.deparment_id
                  AND employee.department_name =
                      NVL(deparment.name, 'Mathematics');  
Kaushik Nayak
  • 30,772
  • 5
  • 32
  • 45
Alok
  • 61
  • 1
  • 8