Question: I am trying to create a temporary table and add information from another table into it. However I keep getting the error

> 
> You have an error in your SQL syntax; check the manual that
>  corresponds to your MySQL server version for the right syntax to use
>  near 'SELECT course\_name, ins\_name FROM courses where
>  course\_name='ACCA'' at line 2'
> 
> 
> 

Can somebody tell me what I am doing wrong?

Here is my code:

```
INSERT INTO #TempTable (course, ins) 
  SELECT course_name, ins_name
  FROM courses
  where course_name = 'ACCA'

```

Answer: 
You should create the temp table first 

```
 CREATE TEMPORARY TABLE 
 IF NOT EXISTS your_table  AS (SELECT course_name, ins_name
             FROM courses 
             where course_name='ACCA');

```
your syntax is fine. However in order to use it you must first create table `#TempTable`.

More details [Here](http://dev.mysql.com/doc/refman/5.7/en/ansi-diff-select-into-table.html)