>我有两个SPARK SQL表,如下所示,
表1
email | client_ip | travelling_method | travelling_code
person1@abc.com |203.22.22.22 | Car | car001
person1@abc.com |203.22.22.22 | Jeep | jeep001
表2
email | client_ip | account_type | trav_code
person1@abc.com |203.22.22.22 | true | car
person1@abc.com |203.22.22.22 | false | jeep
我的查询如下,
SELECT table1.email, table1.client_ip, table1.travelling_method, table1.travelling_code, table2.account_type FROM table1 LEFT JOIN table2 ON table1.email = table2.email AND table1.client_ip = table2.client_ip AND table1.travelling_code LIKE CONCAT('%' ,table2.trav_code, '%') WHERE table1.email = 'person1@abc.com';
我编写了上面的查询来获得以下输出,但它给我抛出了一个异常。
所需的输出为:
email | client_ip | travelling_method | travelling_code| account_type
person1@abc.com |203.22.22.22 | Car | car001 | true
person1@abc.com |203.22.22.22 | Jeep | jeep001 | false
如果有人可以帮助我指出我在查询中缺少什么,请不胜感激。 :)
尝试在正确的位置写" where "
SELECT table1.email, table1.client_ip, table1.travelling_method, table1.travelling_code, table2.account_type
FROM table1 LEFT JOIN table2 ON table1.email = table2.email WHERE
table1.client_ip = table2.client_ip
AND table1.travelling_code LIKE CONCAT('%' ,table2.trav_code, '%') and table1.email = 'person1@abc.com'
我没有测试您的查询。如果仍然遇到错误,则发布错误消息。