Question: I am trying to execute the following query:

```
UPDATE table1 SET column1 = NULL 
 WHERE column1 = (SELECT column1 
                    FROM table1 
                   WHERE id = @id)

```

on MySQL server but I get the follwing error message:

"Error Code: 1093. You can't specify target table 'table1' for update in FROM clause"

This works in Microsoft SQL Server. Any ideas on how to get it to work on MySQL?

Thanks

Answer: 
Add an extra `SELECT` to the inner query. This will act as a "different" table since you are selecting from `a` instead of `table1`:

```
UPDATE table1
SET column1 = NULL
WHERE column1 = (
  SELECT column1 FROM (
    SELECT column1
    FROM table1
    WHERE id = @id
    )a);

```

`[sqlfiddle demo](http://sqlfiddle.com/#!2/a8d903)`
Off the top of my head, a couple of things you can try:

1) try giving each table1 use an alias
2) using 'in' instead of '=' since you could get multiple results from the select

```
UPDATE table1 t1 SET t1.column1 = NULL WHERE t1.column1 IN (SELECT t2.column1 FROM table1 t2 WHERE id = @id)

```

3) failing these, maybe use a temp table?