如何解决“from关键字not found where expected”错误

dzhpxtsq  于 2021-07-26  发布在  Java
关注(0)|答案(2)|浏览(715)
SELECT o.orderid,o.orderdate,
p.productid,o.orderid
o.productstandardprice,
o.productstandardprice*o.ordered_quantity as order_sales_price 
FROM orders_t o and products_t p
WHERE p.productid = o.productid;

我已经得到了错误ora-00923:从关键字没有找到预期的地方,我不知道该怎么办

bvhaajcl

bvhaajcl1#

正确使用join。 SELECT o.orderid, o.orderdate, p.productid, o.orderid, o.productstandardprice, o.productstandardprice*o.ordered_quantity as order_sales_price FROM orders_t o join products_t p on p.productid = o.productid;

ryevplcw

ryevplcw2#

你的问题是 FROM 您应该使用的子句 JOIN :

SELECT o.orderid, o.orderdate, p.productid, o.orderid, 
       o.productstandardprice,
       (o.productstandardprice * o.ordered_quantity) as order_sales_price 
FROM orders_t o JOIN
     products_t p
     ON p.productid = o.productid;

然而,唯一的专栏来自 products_tproducctid --而这已经在 orders_t . 我怀疑 JOIN 用作过滤器,因此应等效于:

SELECT o.orderid, o.orderdate, o.productid, o.orderid, 
       o.productstandardprice,
       (o.productstandardprice * o.ordered_quantity) as order_sales_price 
FROM orders_t o ;

也就是说,只有 orders_t 似乎有必要进行此查询。

相关问题