如何在mysql查询中连接两个不同的视图

时间:2014-02-15 10:29:04

标签: mysql sql

我有两个观点:

  1. vbsleads.mview_leads
    我想要显示的列列表

    • LEADDATE

    • LEADSID

    • FULLNAME

    • ADDRESS

    • SOURCENAME

    • MOBILEPHONE

    • PROBLEM

    • LEADASSIGNEDTO

  2. vbsleads.view_validaccounts
     我想要显示的列列表

    • UID

    • FIRSTNAME

  3. 我想在单个mysql查询中显示上面的列。我如何连接它们?

1 个答案:

答案 0 :(得分:1)

尝试这样

 SELECT mvl.LEADSID, mvl.LEADSID,mvl.FULLNAME,mvl.ADDRESS,mvl.HOURS_SPENT,
 mvl.SOURCENAME,mvl.MOBILEPHONE,mvl.PROBLEM,mvl.LEADASSIGNEDTO,vv.UID,
 vv.FIRSTNAME
 FROM  vbsleads.mview_leads mvl
 JOIN vbsleads.view_validaccounts vv ON (mvl.COMPANYID=vv.COMPANYID)