我有两个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
感谢是否有人可以帮助我指出我的查询中缺少的内容。 :)
答案 0 :(得分:0)
尝试写作"在哪里"在正确的地方,如
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'
我没有测试你的查询。如果仍然面临错误,则发布错误消息。