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;
正确使用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;
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;
SELECT o.orderid, o.orderdate, o.productid, o.orderid,
o.productstandardprice,
(o.productstandardprice * o.ordered_quantity) as order_sales_price
FROM orders_t o ;
2条答案
按热度按时间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;
ryevplcw2#
你的问题是
FROM
您应该使用的子句JOIN
:然而,唯一的专栏来自
products_t
是producctid
--而这已经在orders_t
. 我怀疑JOIN
用作过滤器,因此应等效于:也就是说,只有
orders_t
似乎有必要进行此查询。