使用Oracle进行简单的SQL查询时出现问题

时间:2013-12-19 03:22:17

标签: sql database oracle

我试图在SQL中自我教育,以便更好地在工作中使用数据库。我目前正在尝试在Oracle Application Express中编写一个SQL查询,它将为我提供管理报告,但是我收到以下错误消息:

  

ORA-01747:user.table.column,table.column或列规范无效

我花了无数个小时寻找错误并进行研究而我无处可去,这让我非常沮丧,因为我觉得它可能相当简单。我的研究告诉我,我的错误的可能原因是我试图引用列名,但使用的列名是Oracle中的保留字。不幸的是,我无法确定究竟是什么......请参阅下面的代码:

SELECT Channel.Channel_Number, Supplier.Supplier_Name, package.Package_Name, Program.Program_name, Rating.Rating_Code, Weekly_Guide.ShowTime
    FROM Channel, Supplier, package, Program, Rating, weekly_guide, channel_package
    Where weekly_guide.date = ''
        AND channel.channel_number = weekly_guide.channel_number
        AND weekly_guide.Program_ID = Program.Program_ID
        AND channel.channel_number = channel_package.channel_number
        AND channel_package.package_ID = package.package_ID
        AND Program.rating_code = rating.rating_code
        AND Program_list.Program_ID = Program.Program_ID
        AND Program_list.list_ID = list.list_id
        AND list.supplier_ID = Supplier.supplier_ID

1 个答案:

答案 0 :(得分:2)

您的Where子句中最有可能是date。您需要将保留字包装在引号中。该名称将区分大小写,因此请确保您在查询中具有正确的日期大小

SELECT Channel.Channel_Number, Supplier.Supplier_Name, package.Package_Name, Program.Program_name, Rating.Rating_Code, Weekly_Guide.ShowTime
FROM Channel, Supplier, package, Program, Rating, weekly_guide, channel_package
Where weekly_guide."date" = ''
    AND channel.channel_number = weekly_guide.channel_number
    AND weekly_guide.Program_ID = Program.Program_ID
    AND channel.channel_number = channel_package.channel_number
    AND channel_package.package_ID = package.package_ID
    AND Program.rating_code = rating.rating_code
    AND Program_list.Program_ID = Program.Program_ID
    AND Program_list.list_ID = list.list_id
    AND list.supplier_ID = Supplier.supplier_ID