Here I have Queried you how to use ‘Exists’ in the select Statement. Inside ‘Select’ statement you cant use ‘IF EXISTS’ so we are going to replace it with ‘WHEN EXISTS’ both are going to work same and Example as follows below.
T_PRODUC and T_Delivery are the table names, we are checking Existance of Specified PID and LOCA, Check the Example Below
WHEN EXISTS(SELECT * FROM T_PRODUC where loca = 'Chennai' and PID=2 )
'Yes' as Availability
'No' as Availability
ExpectedDeliveryDate From T_Delivery