Question: I need single query to execute this function in mysql

```
select * from 'users' where user_name like 'account'

```

if no users with name `account` present then i have to use the second query else i can go with the first query.

```
select * from 'users' where user_name like 'manager'

```

is there any way to optimize this into a single query? Thanks

Answer: 
Something like this should work

```
Select IF ((Select count(*) from 'users' where user_name like 'account')>0,
select * from 'users' where user_name like 'account',
select * from 'users' where user_name like 'manager')

```
```
SELECT m.*
  FROM users m
  LEFT JOIN users a ON a.user_name = 'account'
 WHERE m.user_name = coalesce(a.user_name, 'manager');

```

It will not work properly in case `user_name` is not unique, I thought it should be, actually. It would help to know how table is defined to design the query properly.