sql - Return a NULL value if no record is found -


please me achieve below sceanario.

select * pmdl;  property_name      value ------------- ---------- profile             1010  

select (select value pmdl property_name='profile') value dual; 

-->> getting 1010 value

select * pmdl; no rows selected

select (select value pmdl property_name='profile') value dual; 

-->> if record doesn't exist getting null values.

the same thing have achive in multiple records.

property_name      value ------------- ---------- profile             1010  profile             1020   select (select value pmdl property_name='profile') value dual; 

as getting below error due returning multiple records.

ora-01427: single-row subquery returns more 1 row 01427. 00000 - "single-row subquery returns more 1 row" *cause:
*action:

how retrive multiple records.

try way:

select value pmdl property_name='profile' union select max(value) pmdl property_name='profile' 

if pmdl doesn';t have records second query return null.

if 1st query returns data union remove duplicates 2nd query.


Comments