When deleting any Team from team table, i need to check that teamId is available in other tables or not. for this i am using following query:-
select count(TeamId) from
( select TeamId from Project union all
select TeamId from TeamMember union all
select TeamId from Department union all
select TeamId from Role union all
) as Id where TeamId = 1
this query is working fine, and returns number of count.
but now i need name of that table and its column, where i found that teamId.
if it is possible than please give me right solution.
thanks in advance..
I don’t see why you need the “column” where it was found, since in all cases you listed “TeamId”. If it were named different things in different tables instead, then you could use this:
And finally, if you wanted the “row” (record) instead, you can add the ID into the column: