Question: I would like to check every so often if exists a new version of my app, and if it´s, show a message to user. I use Firebase, connecting and comparing version from remote config with current version of app. This isn´t the problem, my problem is how to show the dialog at any time, in any activity. 

I have a BaseActivity, where I have methods to connect with firebase and to show the message when it answers. Furthermore, I have a method that executes every hour this update checking:

```
    private void checkUpdate() {
        handlerCheckUpdate.postDelayed(() -> {
            getConfigFromFirebase(this);
            checkUpdate();
        }, 3600000);
    }

```

And finally I have Activity1 and Activity2 that extends of BaseActivity. In my Activity1 I start the recursive checkUpdate method. 

The problem is that, if user is in Activity2 currently, when the message shows, it do it in Activity1 and not in Activity2.
What is the best solution to do this?.

Thank you very much!

Answer: 
You can get this result with a `JOIN`, by self-joining on the `color` field, where the name in the second table is `jose`:

```
SELECT a1.name, a1.color
FROM tableA a1
JOIN tableA a2 ON a2.color = a1.color AND a2.name = 'jose'

```

Output

```
name    color
jose    red
Rap     red

```

[SQL Server demo on SQLFIddle](http://sqlfiddle.com/#!18/5f7e3/5)

[Oracle demo on SQLFiddle](http://sqlfiddle.com/#!4/5f7e3/1)
I think the best way is "CTE" :

```
     with 
     cte1 as (
          select 1 as RowToJoin,
                 name,
                 color 
          from tableA
     ),
     cte2 as (
          select 1 as RowToJoin,
                 color
                 name
          from tableA 
          where name='jose'
     )
     select c1.name, c1.color
     from cte1 c1
     join cte2 c2 on c2.RowToJoin = c1.RowToJoin
     where c1.name <> c2.name

```

It looks as something hard, but it's simple. Try to read about it.!