错误:缺少表格“电影”的FROM子句条目

时间:2015-11-13 21:29:27

标签: postgresql

我是SQL的新手,需要查询数据库以提取某些信息,然后才能将其导入到我熟悉的另一个分析数据的软件中。此查询是由我目前无法访问的朋友发送给我的,我无法弄清楚为什么它会给我以下错误:

ERROR:  missing FROM-clause entry for table "movies"
LINE 8: FROM (SELECT movies.movieid

以下是查询:

SELECT innerselect.movieid
       ,innerselect.title
       ,innerselect.year
       ,innerselect.imdbid
       ,innerselect.budget[1] AS budget_currency
       ,TO_NUMBER(innerselect.budget[2], '999999999999990.00') AS budget_total
       ,innerselect.businesstext
FROM (SELECT movies.movieid
       ,movies.title
       ,movies.year
       ,movies.imdbid
       ,business.businesstext
       ,regexp_matches(business.businesstext, '^BT:[ ](USD)[ ](-?(?!0)(?:\d+|\d{1,3}(?:,\d{3})+))', 'g') AS budget -- creates a PostgreSQL Array which contains the content matched with the RegEx Groups FROM movies LEFT JOIN business ON movies.movieid=business.movieid WHERE movies.movieid > 2753500
) AS innerselect

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

问题是你把FROM放在与注释相同的行上,所以忽略了FROM子句。

SELECT innerselect.movieid
       ,innerselect.title
       ,innerselect.year
       ,innerselect.imdbid
       ,innerselect.budget[1] AS budget_currency
       ,TO_NUMBER(innerselect.budget[2], '999999999999990.00') AS budget_total
       ,innerselect.businesstext
FROM (SELECT movies.movieid
       ,movies.title
       ,movies.year
       ,movies.imdbid
       ,business.businesstext
       ,regexp_matches(business.businesstext, '^BT:[ ](USD)[ ](-?(?!0)(?:\d+|\d{1,3}(?:,\d{3})+))', 'g') AS budget -- creates a PostgreSQL Array which contains the content matched with the RegEx Groups
      FROM movies LEFT JOIN business ON movies.movieid=business.movieid WHERE movies.movieid > 2753500
) AS innerselect