在AppMaker中使用计算模型联接两个大表

时间:2018-12-26 21:09:38

标签: sql google-app-maker

我在Google AppMaker中有两个SQL数据源。两者中都将有成千上万的记录:

LastLogins:

+-------------------+-----------+
|       Email       | LastLogin |
+-------------------+-----------+
| email@domain.com  | 1/1/2019  |
| email2@domain.com | 12/1/2018 |
+-------------------+-----------+

和许可证:

+------------------+---------+------------+
|      Email       |  SkuID  |  SkuName   |
+------------------+---------+------------+
| email@domain.com | 1001001 | Enterprise |
| email2@domain.com| 1001001 | Basic      |
+------------------+---------+------------+

我想加入表以使用以下数据创建计算出的数据源:

+------------------+---------+------------+-----------+
|      Email       |  SkuID  |  SkuName   | LastLogin |
+------------------+---------+------------+-----------+
| email@email.com  | 1001001 | Enterprise | 1/1/2019  |
| email2@email.com | 1001001 | Basic      | 12/1/2018 |
+------------------+---------+------------+-----------+

我尝试了几种不同的join命令,但没有一个起作用。这是我当前的迭代:

select 
    m.Email,
    m.SkuID,
    m.SkuName,
    l.Email,
    l.LastLogin
from Licenses m ,LastLogins l
full join LastLogins on Licenses.Email = LastLogins.Email

我得到的错误是;

  

异常:格式错误的SQL。详细信息:SQL语句出错:   您的SQL语法有误;检查手册   对应于您的MySQL服务器版本以使用正确的语法   接近“完全加入Licenses.Email = LastLogins.Email LIMIT上的LastLogins”   26'在第3行。

1 个答案:

答案 0 :(得分:1)

您快到了,但是JOIN表的语法错误。

语法是:

FROM <table1> as <alias1>
INNER JOIN <table2> as <alias2> ON ...

尝试:

select 
    m.Email,
    m.SkuID,
    m.SkuName,
    l.LastLogin
from Licenses as m
inner join LastLogins as l on l.Email = m.Email