Q: Update column from another table mysql I have 2 tables(violator and officer) and both of them have column name reference, now what I want to do is whenever I add a new value to the violator table, the value of its reference should be equal to the value of reference on officer table. I am new to programming but how can I achieve that? I couldn't quite understand the notes I can find on the internet. This is how I add values to the violator table: 
php 
<?php
$user_name = "Demo";
$password = "Demopass";
$server = "localhost";
$db_name = "TMTRO";

$con = mysqli_connect($server, $user_name, $password, $db_name);
if ($con) {

    $Name = $_POST['name'];
    $LName = $_POST['lname'];
    $LNumber = $_POST['lnumber'];
    $Violation = $_POST['violation'];
    $Aplace = $_POST['aplace'];
    $Address = $_POST['address'];
    $PNumber = $_POST['pnumber'];
    $OName = $_POST['oname'];
    $RNumber = $_POST['rnumber'];
    $DTime = $_POST['dtime'];
    $query = "insert into violators (name,lname,lnumber,violation,aplace,address,pnumber,oname,reference,datetime) values ('" . $Name . "','" . $LName . "','" . $LNumber . "','" . $Violation . "','" . $Aplace . "','" . $Address . "','" . $PNumber . "','" . $OName . "','" . $RNumber . "','" . $DTime . "');";
    $result = mysqli_query($con, $query);

    if ($result) {

        $status = 'OK';


    } else {
        $status = 'FAILED';
    }

} else {
    $status = 'FAILED';
}

echo json_encode(array("response" => $status));

mysqli_close($con);

?>

