I have a table `Users` with four columns like:

```
Users
- username
- email
- address
- name

```

Given a username and email, I want to find a single user in my table who has the same username and email, or the same username with the email not matching any other users, or the same email with the username not matching any other users.

For example, if this is my table:

```
username   email            address     name     id
jbrian     jbr@gmail.com     ""         John      1
gpaul                        ""         George    2
""         gpaul@gmail.com.  ""         George    3
""         tking@gmail.com.  ""         Tom       4

```

Searching for username `jbrian` and email `jbr@gmail.com` should return `id` 1.

Searching for username `gpaul` and email `gpaul@gmail.com` should return nothing, because they are for different users.

Searching for username `tking` and email `tking@gmail.com` should return `id` 4 because the email matches and there are no other matches for the username.

I put this together - `select users.id from users where username='gpaul' or email='gpaul@gmail.com' limit 1`

But this would always return one result. I'm not sure how to enforce the constraint that only one result should be returned, or else nothing should be returned.