msg_key user_key team_key message_text msg_date
1 11727 21 hello how are you 03-03-2016 20:00:00
2 11678 21 i am fine 03-03-2016 20:00:00
3 11735 124 access the system 03-03-2016 20:00:00
now, requirement is I would like to have a view, where while retrieving data from that I will the pass the user_key and view will return the all message_text for the team_key under which that user belongs to.
like if I pass user_key as 11727 or 11678 , both the cases I should get two rows they belongs to same team_key ie. 21, but for user_key 11735 will return one row.
yes, you are right, that above query can resolve the requirement.
But the problem is I do not want to give access the direct table, but want to have view to having table data and passing the user_key should give the same result as your query.
the view will be accessed by the application where user will pass the user_key.