I need some condition on insert statement to prevent unauthorized insertions.
I wrote something like this:

```
INSERT INTO `fund` (amount,description)
    SELECT 1000,'Some description'
    WHERE 12 IN (SELECT id FROM users WHERE allow_add=1)

```

Where 12 is the id of current user.
But mysql process stopped unexpectedly!
I use XAMPP with MySQL version: 5.5.5-10.1.13-MariaDB.
Note that I ran this code before this in SQL Server without any problem.
Any Idea?
['https://Stackoverflow.com/questions/46905636', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5259185/']
With thanks to [P.Salmon answer](https://stackoverflow.com/a/46906663/5259185), I found the solution. It seems that MySQL needs FROM statement in conditional SELECT, unlike the SQL Server. So, I add a temporary table name as below:

```
INSERT INTO `fund` (amount,description)
SELECT 1000,'Some description'
FROM (SELECT 1) t
WHERE 12 IN (SELECT id FROM users WHERE allow_add=1)

```
It is not a proper way to authorize insertions in database. Instead, you can use programming based solution for this problem.

In PHP, a proper solution could be:-

```
if ($user->allow_add == 1){ //where $user is the User instance for current user
    $sql->query("INSERT INTO `fund` (amount,desc) VALUES(1000,'Some desc')");
}

```