Question: I'm trying to set the [9 patch](http://developer.android.com/tools/help/draw9patch.html) image attached below as my layouts background.It looks good on few device backgrounds and few devices shows consecutive circles in center which makes the UI inconsistent. I want consistent over all the device densities. How can I achieve the UI appearance on all devices being consistent?

![enter image description here](https://i.stack.imgur.com/RQcxY.png)

Answer: 
Just try this query:

```
SELECT threads.id
FROM threads 
INNER JOIN thread_user ON thread_user.thread_id = threads.id
INNER JOIN messages ON messages.thread_id = threads.id
WHERE thread_user.user_id = 1
AND threads.draft = false
AND messages.user_id != 1

```

INNER JOIN give you the intersection between two table based 'ON' your condition **"thread\_user.thread\_id = threads.id"** 

your 1st query give u the intersection between threads, and thread\_user --> as table\_1
and your 2nd one give u the intersection between threads, and messages --> as table\_2

what I done is simply getting the intersection between messages, and table\_1 -which is the intersection between threads, and thread\_user-

and I collect your conditions from the two queries, and add it to the new query.
In this particular case you can just use one query with 2 INNER JOIN like this:

```
SELECT 
  threads.id
FROM threads 
INNER JOIN thread_user ON thread_user.thread_id = threads.id AND thread_user.user_id = 1
INNER JOIN messages ON messages.thread_id = threads.id AND messages.user_id != 1
WHERE threads.draft = false

```

Thus the inner join will "kind of" do the intersection for you.