没有用我的pgsql Join定义的关系

时间:2017-05-04 14:55:39

标签: postgresql

我是新手,并且无法为我的桌子加入找到合适的语法...

SELECT
DISTINCT on (date (billing.starttime))
medias.name,
date (billing.starttime),
Count(distinct (billing.starttime)) as "# Plays",
Count(distinct(billing.playerid)) as "# Stores"

FROM
public.billing,
public.medias

JOIN ????? on billing.mediaitemid = medias.id

WHERE
medias.name LIKE any (array['COMM_7032%']) and
billing.starttime >= date('2017-04-26') and 
billing.starttime < date('2017-05-01') 

GROUP BY
date (billing.starttime),
medias.name

ORDER BY
date (billing.starttime)

我不确定什么适合?????是。我所尝试的一切都表明这种关系不存在。

2 个答案:

答案 0 :(得分:0)

from
    public.billing b
    inner join
    public.medias m on b.mediaitemid = m.id

答案 1 :(得分:0)

应该去:

...
FROM
public.billing JOIN public.medias on billing.mediaitemid = medias.id
WHERE
...

语法是

[table1] join [table2] on [condition]