Hi;
I have 2 tables and I would like to add a new record into another table by two conditions
- the level should be equal to "3"
- the table should have not the same two values in a record
Here is my code, its working on mysql side but couldnt implement on phprunner
INSERT INTO table2 (Position,User,AddedBY)
SELECT Position,User,AddedBY
FROM table1
WHERE NOT EXISTS (SELECT Position, User
FROM table2
WHERE Position=Position and User=User)
AND table1.userlevel='3'
I also tried
$sql = "INSERT INTO table2 (Position, User, AddedBY) ";
$sql .= "SELECT Position, User, AddedBY FROM table1 WHERE NOT EXISTS (SELECT Position, User FROM table1 WHERE Position=".$values[Position]." and User=".$values[User].") AND userlevel=='9'";
DB::Query($sql);
I apprecate for any idea or help
Thanks in advance