Note: This is an over simplified version of what I am trying to do.
Let's say I have a table called USERS that has FIRSTNAME, LASTNAME. Contents are:
JOHN SMITH
DAVID BECKHAM
ELON MUSK
I want to query this table so that if a value exists it just returns that value, otherwise it returns the whole table. Example:
SELECT *
FROM USERS
WHERE FIRSTNAME = 'JOHN'
This would return
JOHN SMITH
However if the query was
SELECT *
FROM USERS
WHERE FIRSTNAME = 'JANE'
Then the return would be
JOHN SMITH
DAVID BECKHAM
ELON MUSK
This is being done in SQL Server but there is potential for Oracle too in case it is different.