Question: I am trying to create an SQL query that compares two databases with each other, however also will not result in a query failure if one of the database rows has not been created elsewhere yet.

Here's what I've gotten so far (a bit of pseudo code)

`$Query="SELECT * FROM campaigns,statistics WHERE statistics.dataDate = '$todaysDate' OR statistics.dataDate DOES NOT EXIST AND where campaigns.campaignName = 'example'";`

The "DOES NOT EXIST" part is where I need the help, how can I create a query that allows the query to continue with more checks if the row has not been created yet?

Thanks very much for any suggestions! I've taken a look around and can't find a solution that checks if the row doesn't exist **inside of the query** (will be needed for when the query is built out a bit further)

Thanks again,

Ash

**edit:**

To clear up any confusion here's a second example:

```
`$Query="SELECT * FROM campaigns,statistics WHERE campaigns.campaignName = '$randomVar' AND (campaigns.budget > statistics.budget OR statistics.budget DOES NOT EXIST )";`

```

I have created this example showing that if the budget does not exist (we would treat it as 0) and still return the results because the budget field hasn't been created yet elsewhere in the platform. If I run the query without this extra "OR" it will look something like this:

```
    `$Query="SELECT * FROM campaigns,statistics WHERE campaigns.campaignName = '$randomVar' AND (campaigns.budget > statistics.budget)";`

```

The problem with this is that in my platform so far the statistics.budget is not always created before this query is ran, therefor if it doesn't have a row I'm happy for the query to treat it as 0

Thanks!

Ash

Answer: 
Its quite easy to get a cell you need to change, but you have to know which row of your table it is:

```
class MyCell : UITableViewCell {

    @IBOutlet weak var myLabel: UILabel!

}

class TableViewController: UITableViewController {

    ...

    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

        let row = 7 //or what you set
        let cellWhereIsTheLabel = tableView.cellForRow(at: IndexPath(row: row, section: 0)) as! MyCell
        cellWhereIsTheLabel.myLabel.text = "Done"

    }

    ...

}

```
A solution will be to update the datasource of your tableview. 

When user taps on cell, `didSelectRowAtIndexPath` is called. In this function you can update datasource to provoke changes in other cells and then call `reloadData` to apply changes. 

When you call `reloadData` tableView is updated by `cellForRowAtIndexPath`. This function uses your datasource to update cell.