I have a problem with my SELECT query. I try to retrieve a tagValue name "CallsBy", but only if the value is "Entry point" - otherwise I want to compute the calls by another sub query.
I have 3 tables :
- t_object: with all the classes
- t_operation: with all the operations, link with t_object.Object_ID = t_operation.Object_ID
- t_operationtag: with all the tag value for each operation, link with t_operation.OperationID = t_operationtag.ElementID
Here is a demo with my tables I have:
https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=b6a1672948db816aefb23b8dc8d8e01d
The result for the class 1 would be :
Name Operation | CallsBy
-----------------+------------------------------------
class1Operation1 | class2Operation2, class3Operation1
class1Operation2 | class2Operation3
class1Operation3 | class2Operation3
The result for the class 2 would be :
Name Operation | CallsBy
-----------------+----------------------------------------------------
class2Operation1 | class1Operation1, class3Operation1,class3Operation3
class2Operation2 | Entry point of Tabidi
class2Operation3 | class1Operation1
The result for the class 3 would be :
Name Operation | CallsBy
-----------------+---------------------------------------
class3Operation1 | class1Operation2, class3Operation1
class3Operation2 | Entry point of Tabada
class3Operation3 | class2Operation1
Here is the sub query to compute the CallsBy if is not a "Entry point" :
select
t2.name, group_concat(t1.name)
from
t_operation t1
left join
(select to3.ElementID, to2.name
from t_object to1
left join t_operation to2 on to1.Object_ID = to2.Object_ID
left join t_operationtag to3 on find_in_set(to2.Name, to3.VALUE)
where to3.Property = 'Calls'
and to1.Object_ID = '1') t2 on t1.OperationID = t2.ElementID
where
t2.ElementID is not null
group by
t2.name;
I try to write the query but I didn't get any result...