SQL query to return a string, even if not found, at least in the parameters

I would like to write an SQL query (oracle) to know whether the operation (identified by ope.ope_operationid) has at least an operation of a certain type (opt.opt_id), and if not, show that it is not in the results.

For example, I have this operation LAA351BP (I know that it exists in the database), and I would like to know if it even has a type of operation whose id is 3781. If it is, print everything if it is not, print the operationid file and something like "not found" next to it

Is the nvl function used? I can't seem to get it to work correctly.

SELECT  DISTINCT ope.ope_operationid,
ser.ser_code,
opt.opt_code,
ost.ost_code
FROM    od_operation ope, 
od_service_type ser,
od_operation_type opt,
od_status_type ost,
od_equipment_type eqt,
WHERE   ope.ser_id = ser.ser_id
AND     opt.opt_id = ope.opt_id
AND     ost.ost_id = ope.ost_id
AND     ope.opt_id = 3781
AND     ope.ope_operationid = 'LAA351BP'

thank

0
source share
1 answer

JOIN. ( , ), , WHERE. , (+), Oracle ( , JOIN)

, ( ) :

SELECT DISTINCT ope.ope_operationid,
       ser.ser_code,
       opt.opt_code,
       ost.ost_code
FROM od_operation ope, 
   LEFT JOIN od_service_type ser ON ope.ser_id = ser.ser_id
   LEFT JOIN od_operation_type opt ON opt.opt_id = ope.opt_id
   LEFT JOIN od_status_type ost ON ost.ost_id = ope.ost_id
   LEFT JOIN od_equipment_type eqt ON ????????
WHERE ope.opt_id = 3781
AND   ope.ope_operationid = 'LAA351BP'

Edit

od_equipment_type , JOIN. SQL , , , .

JOIN , . , FROM, , WHERE

+5

All Articles