我正在尝试合并多个表。我就是这样做的:
CREATE TABLE big3 AS SELECT *
FROM trainSearchStream a
LEFT OUTER JOIN SearchInfo b ON b.SearchID=a.SearchID LIMIT 3
LEFT OUTER JOIN AdsInfo c ON c.AdID=a.AdID LIMIT 3;
然而,我收到此错误:
错误:接近" LEFT":语法错误
答案 0 :(得分:1)
正如jarlh已经提到的,每个选择语句只能有一个LIMIT。
所以这是禁止的:
select *
from a limit 5
join b limit 6 an a.x = b.x;
但这是允许的:
select *
from (select * from a limit 5) alim
join (select * from b limit 6) blim on alim.x = blim.x;
但是,您只是想测试您的查询,我建议您从trainSearchStream中获取样本进行测试。模数运算符%非常适合采样:
CREATE TABLE big3 AS SELECT *
FROM (select * from trainSearchStream where searchid % 12345 = 6789) a
LEFT OUTER JOIN SearchInfo b ON b.SearchID = a.SearchID
LEFT OUTER JOIN AdsInfo c ON c.AdID = a.AdID;
为模数操作选择您喜欢的任何数字。上面的语句将您的trainSearchStream计数除以约12345(假设ID均匀分布)。