I’m trying to achieve the following in SQL Server 2005:
SELECT (IF EITHER EXISTS) usr.username, pro.email FROM table1 AS usr, table2 AS pro WHERE usr.username = 'existing_username' AND / OR pro.email = 'existing_email'
I can’t figure out how to write something like that. Basically I want it to return the username if it finds an existing one, and return the email if it finds one.
So it would return to me: username, email, both or none
Is this possible???
Its not really clear what you want. Since you’re not joining the tables I’m assuming you really want the union of the two
If you want to know where it came from you could do