2013-05-20 149 views
-7

我在我的數據庫上有一些表,我正在使用MySQLSQL查詢創建視圖

請參見下圖。這是我的數據庫的簡單版本

如何創建查看用戶詳細信息?

enter image description here

+2

哪裏**正確**你卡? – Jocelyn

回答

4
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 

爲了進一步獲得更多的知識有關聯接和MySQL的意見,請訪問以下鏈接:

0
create view view1 
as 
    select ud.id_user_detail, cp.category_province_content, 
    cc.category_city_content, cj.category_job_content 
    from user_detail ud, category_province cp, 
    category_city cc, category_job cj 
    where ud.detail_province=cp.id_category_province 
    and ud.detail_city=cc.id_category_city 
    and ud.detail_job=cj.id_category_job