Subject | Re: [ib-support] Rationalise SQL Statement |
---|---|
Author | Svein Erling Tysvaer |
Post date | 2003-06-10T12:21:36Z |
At 11:48 10.06.2003 +0000, you wrote:
SELECT <all-you-want-to-select>
FROM databox a
LEFT JOIN databox_users u ON u.dbox_id = a.dbox_id and u.user_id =
'AAVUR0000000001'
WHERE a.max_users is not null
You'd probably need a subselect for your 'selected' column, though, I
cannot see how else to include 'T' only for those columns that match
databox_users (I'm not saying that it is impossible, just that I cannot see
how to do it).
HTH,
Set
>Select (select 'T' from databox_users u where u.dbox_id = a.dbox_idWell, at least most of it can be rewritten:
>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?
SELECT <all-you-want-to-select>
FROM databox a
LEFT JOIN databox_users u ON u.dbox_id = a.dbox_id and u.user_id =
'AAVUR0000000001'
WHERE a.max_users is not null
You'd probably need a subselect for your 'selected' column, though, I
cannot see how else to include 'T' only for those columns that match
databox_users (I'm not saying that it is impossible, just that I cannot see
how to do it).
HTH,
Set