Question: I am using the Morris Bar Chart to display the number of times a user has logged in into the system. I would like to have dynamic label ( on hovering). I am getting the data through PHP.

```
<?php
    $conn = mysqli_connect("localhost", "root", "", "database_name");
    $sql = "SELECT account, 
                        (SELECT fullname 
                        from employees as d 
                        WHERE r.emp_id = d.employee_code) as emp_id, 
                        count(username) as total
            From logins as r 
            group by account 
            ORDER BY emp_id ASC 
            LIMIT 10";

    $most_link =mysqli_query($conn,$sql);
    $chart_data = '';
    $most_sold = '';

    while($row_most= mysqli_fetch_array($most_link)){
        $most_sold .= "{ accounnt:'".$row_most["account"]."',  employee:'".$row_most["emp_id"]."', total:".$row_most["total"].", }, ";
    }
    $most_sold = substr($most_sold, 0, -2);
?>
<script>
    new Morris.Bar({
        element : 'most',
        data:[<?php echo $most_sold; ?>],
        xkey:'employee',
        ykeys:['total'],
        labels:'account',
        hideHover:'auto',
        barColors:['#F5761A'],
    });
</script>

```

If you notice, the labels are hardcoded to 'account(the label text words)', However, I would like it to be dynamic ( 'account' attribute in PHP ). Any idea how it can be done ?

Answer: 
The basic statement you need is as follows. Using the *inserted* table which contains only the row(s) inserted for the current server process, join back to the table on its primary key and update only the inserted rows which are not blank (and implied also not NULL).

```
update s 
  set s.email = Concat(s.FirstName, '.', s.LastName, '@youremail.com')
from inserted i 
join Studentinformation s on s.StudentId = i.StudentId 
where i.email != '';

```
I complete the answer with `ISNULL` function.

```
CREATE TRIGGER trg_assignEmail ON Studentinformation
After INSERT
AS  
    UPDATE s
      SET Email = Isnull(i.Email, Concat(i.FirstName, '.', i.LastName,'@youremail.com'))
    FROM inserted i JOIN Studentinformation s on s.StudentId = i.StudentId

```