Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return full list, even when not found

Status
Not open for further replies.

TyzA

Programmer
Jan 7, 2002
86
0
0
BE
Hi,

Is the following possible:
Code:
select *
from table_x
where field_x in (value_x, value_y, value_z)

value_y doesn't exist in the table thus logically speaking the query would only return the results for value_x and value_z.

Now my questions is, can I also retrieve a blank row for value_y via a select statement?
The result would be like:
row value_x
row value_y (all null values)
row value_z

With stored procedures/functions this is easy to but unfortunately I can't make use of these.

Any idea's.

Tx,
Tijs
 
Something like that usually is done by means of an outer join;
the following may look a bit ugly, but it should work:
Code:
select d.field_x, t.other_field from table_x t
right outer join
(
select 'value_x' as field_x from dual
UNION
select 'value_y' as field_x from dual
UNION
select 'value_z' as field_x from dual
) d
on t.field_x = d.field_x
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top