Subject | Rationalise SQL Statement |
---|---|
Author | Ian A. Newby |
Post date | 2003-06-10T11:48:55Z |
Hi Folks,
I have the following sql statement:
Select (select 'T' from databox_users u where u.dbox_id = a.dbox_id
and u.user_id = 'AAVUR0000000001') as selected,
(select valid_from from databox_users u where u.dbox_id = a.dbox_id
and u.user_id = 'AAVUR0000000001') as valid_from,
(select valid_to from databox_users u where u.dbox_id = a.dbox_id
and u.user_id = 'AAVUR0000000001') as valid_to, a.dbox_id, a.title
from databox a where a.max_users is not null
is there any way it can be rewritten to avoid three seperate
subselects?
TIA
Ian Newby.
I have the following sql statement:
Select (select 'T' from databox_users u where u.dbox_id = a.dbox_id
and u.user_id = 'AAVUR0000000001') as selected,
(select valid_from from databox_users u where u.dbox_id = a.dbox_id
and u.user_id = 'AAVUR0000000001') as valid_from,
(select valid_to from databox_users u where u.dbox_id = a.dbox_id
and u.user_id = 'AAVUR0000000001') as valid_to, a.dbox_id, a.title
from databox a where a.max_users is not null
is there any way it can be rewritten to avoid three seperate
subselects?
TIA
Ian Newby.