Question: I know there are lot of answers to this question . But it didn't achieved the desired result . didDEselectrow is not working . I have a UIImageView which i have set to hidden True in cellforRowAtIndex. And when someone selects any row value for hidden is set to false . 

\*\*My main problem is when i select another row , the previous row status does not change and it also shows selected . I have attached the necessary snippet of my code ,Please check and help me through this . \*\*

```
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    EventTypeTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"Event_Type" forIndexPath:indexPath];

    cell.selectionStyle = UITableViewCellSelectionStyleNone;

    if (cell.selectionStatus)
        [cell.selectEvent setHidden:NO];
    else
        [cell.selectEvent setHidden:YES];

    [cell.eventTypeName setText:[eventTypeName objectAtIndex:indexPath.row]];

    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
 EventTypeTableViewCell *cell = (EventTypeTableViewCell *)[self.tableView    cellForRowAtIndexPath:indexPath];

    if(cell.selectionStatus == TRUE)
    {
        cell.selectionStatus = FALSE;
    }
    else
    {
]        cell.selectionStatus = TRUE;
    }
    [tableView reloadData];
}

-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
    EventTypeTableViewCell *cell = (EventTypeTableViewCell *)[self.tableView cellForRowAtIndexPath:indexPath];
    if(cell.selectionStatus == FALSE)
    {
        //Do your stuff
        cell.selectionStatus = TRUE;
    }
    else
    {
        //Do your stuff
        cell.selectionStatus = FALSE;
    }
    [tableView reloadData];
}

```

Answer: 
This can be rewritten using an `OUTER JOIN` with a `NULL` check or by using `NOT EXISTS`. I prefer `NOT EXISTS`:

```
SELECT *
FROM Employee e
WHERE NOT EXISTS (
    SELECT 1
    FROM bademployee b
    WHERE e.empid = b.badempid)

```

Here is the `OUTER JOIN`, but I believe you'll have better performace with `NOT EXISTS`. 

```
SELECT e.*
FROM Employee e
    LEFT JOIN bademployee b ON e.empid = b.badempid
WHERE b.badempid IS NULL

```

Here's an interesting article about the performance differences: <http://sqlperformance.com/2012/12/t-sql-queries/left-anti-semi-join>
Whatever someone else may say, you need to check the execution plan and base your conclusion on what that sais. Never just trust someone else that claims this or that, research into his claims and verify that with documentation on the subject and in this case the execution plan which clearly tells you what is going on.

[One example](http://blog.sqlauthority.com/2008/04/22/sql-server-better-performance-left-join-or-not-in/) from SQL Authority blogs shows that the LEFT JOIN solution performs much worse than the NOT IN solution. This is due to a LEFT ANTI SEMI JOIN done by the query planner which generally performs a lot better than a LEFT JOIN + NULL check. There may be exceptions when there are very few rows. The author also tells you afterwards the same as I did in the first paragraph: always check the execution plan.

[Another blog post](http://sqlperformance.com/2012/12/t-sql-queries/left-anti-semi-join) from SQL Performance blogs goes into this further with actual performance testing results.

TL;DR: In terms of performance NOT EXISTS and NOT IN are on the same level but NOT EXISTS is prefered due to issues with NULL values. Also, don't just trust what anyone claims, research and verify your execution plan.