使用where子句时,文件中的外部数据会引发错误

时间:2017-08-18 21:32:54

标签: sql postgresql

我正在尝试读取包含2,000个值的文本文件,但我的where子句会抛出错误。

    SELECT mac.mac_id,mac.mac,mac.mac_type,record.soc_id 
    from mso_charter.mac
    where record.soc_id in ('C:\Users\xyz\worldbox2_Prod_09-17-2017.txt')
    join mso_charter.record on mac.record_id = record.header_id;

    ERROR:  syntax error at or near "join"
    LINE 4: join mso_charter.record on mac.record_id = record.header_id;
            ^
    ********** Error **********

    ERROR: syntax error at or near "join"
    SQL state: 42601
    Character: 155

1 个答案:

答案 0 :(得分:0)

此:

v0.5                                      v0.6

WARNING: rmprocs: process 1 not removed | WARNING: rmprocs: process 1 not removed
20000                                   | 20000
20000                                   | 20000
20000                                   | 20000
    From worker 3:  1                   |       From worker 3:  1
1                                       | 1
    From worker 2:  10000               |       From worker 2:  10000
    From worker 3:  20000               |       From worker 3:  1

除非你有多个soc_Id

SELECT mac.mac_id,mac.mac,mac.mac_type,record.soc_id from mso_charter.mac join mso_charter.record on mac.record_id = record.header_id where record.soc_id in ('C:\Users\xyz\worldbox2_Prod_09-17-2017.txt');

不是这个:

where record.soc_id = ('C:\Users\xyz\worldbox2_Prod_09-17-2017.txt');

编译器非常挑剔订单

  • 选择
  • FROM
  • JOIN
  • WHERE
  • GROUP BY
  • HAVING
  • ORDER BY

虽然执行顺序是

  • FROM
  • JOIN
  • WHERE
  • GROUP BY
  • 选择
  • HAVING
  • ORDER BY