I have a column named Cons in a table named Conses as Order::Resource(PPP32#BB300320LQ00J#AAAR05504)
I have second table which depends on first table.
i wants to get all data from the seconds table and i did it manually as below and result is ok
select * from so_db..item where id =('PPP32' )
and sub_id =('BB300320LQ00J')
and tem_id =('AAAR05504');
but i want to replace inside the parentheses with an other query which must get one part of the column mentioned above as follow:
id = first part of column before '#' character
sun_id = middle part of column between '#' character
tem_id = last part of column
select * from so_db..item where id =( select Cons from er_db..Conses where UsedBy_ = 'mmmf8c713f490f8133c00e16ffdea136add')
and sub_id =(select Cons from er_db..Conses where UsedBy_ = 'mmmf8c713f490f8133c00e16ffdea136add')
and tem_id =(select Cons from er_db..Conses where UsedBy_ = 'mmmf8c713f490f8133c00e16ffdea136add');
Does anybody know how to do this?
The following recommendations will help you in your SQL tuning process.
You'll find 3 sections below:
ALTER TABLE `item` ADD INDEX `item_idx_id_sub_id_tem_id` (`id`,`sub_id`,`tem_id`);
SELECT
*
FROM
so_db..item
WHERE
so_db..item.id = (
'PPP32'
)
AND so_db..item.sub_id = (
'BB300320LQ00J'
)
AND so_db..item.tem_id = (
'AAAR05504'
)