Search code examples
mysqlsqlcreate-view

SQL Query To Create View


I have some tables on my database, I am using MySQL

See the image below. It is the simple version of my database

How to create view the user detail?

enter image description here


Solution

  • CREATE VIEW EmpList
    AS
    SELECT  a.id_user,
            b.category_province_content,
            c.category_city_content,
            d.category_job_content
    FROM    user_detail a
            INNER JOIN category_province b
                ON a.detail_province = b.id_category_province
            INNER JOIN  category_city c
                ON a.detail_city = c.id_category_city
            INNER JOIN category_job d
                ON a.detail_job = d.id_category_job
    

    To further gain more knowledge about joins and MySQL views, kindly visit the links below: