Search code examples
mysqlsqlsql-view

How do inserts into mysql views?


i have 2 tables

table.employees

        id, first_name, last_name, post

table.time

        employee_id, work_time

VIEW

        id, first_name, last_name, work_time

how i can write one insert for VIEW !!?


Solution

  • You can't. It's not (always) possible to determine which values would need to be inserted. For example, your view doesn´t have the post column, which might be required, which would make it impossible to insert through a view.

    As such, VIEWS are for viewing content only; insertions have to be made on the actual database tables.