Question: I have a tablet app with a Master / Detail layout, with a TableView in the Master panel that changes the content of the Detail pane. I'd like to have the master's row stay highlighted when clicked like it does in the android OS settings.

Right now the best I'm able to do is set the `backgroundColor` to a new color in response to a `'click'` event. However, when I do a quick tap, the row highlights, then blinks back to normal before highlighting again. I'm guessing this is the delay between when I lift my finger off and when the backgroundColor gets changed.

```
tableview.addEventListener('click', function(e) {
    ...
    else if (e.rowData.id == 3) { // scan history
        e.row.backgroundColor = 'blue';

```

This appears to be the way others have done it: <http://developer.appcelerator.com/question/124359/android---tableviews-deselectrow>

And if I was just using android and not Titanium: [How can I highlight the table row on click ?](https://stackoverflow.com/questions/4075356/how-can-i-highlight-the-table-row-on-click)

Answer: 
You can use a `left outer join` onto Table2, and then [`COALESCE`](http://msdn.microsoft.com/en-us/library/ms190349.aspx) the Alias and Name results like this:

```
SELECT Table1.ID, COALESCE(Table2.Alias, Table1.Name) AS Name, 
    Table1.Location
FROM Table1
LEFT OUTER JOIN Table2 ON Table1.ID = Table2.ID AND Table2.AliasType = 2

```

`COALESCE` works by finding the first non-null value in the supplied values.
The COALESCE function will let you have a fall-back expression so that the name from table 2 is used if it exists, and the name from table 1 is used otherwise. The LEFT outer join only joins table 2 when the rows exist, and t2.name is null if no record was joined.

`SELECT t1.id, COALESCE(t2.name, t1.name), t1.location FROM [Table 1] as t1 LEFT JOIN [Table 2] as t2 on t1.id=t2.id and t2.[alias type]=2`