0
mysql> select * from pvf_order;
+------+------------+------+
| oid | orderdate | cid |
+------+------------+------+
| 1001 | 2014-02-10 | 1 |
10 rows in set (0.00 sec)
mysql> select * from pvf_order_item;
+------+-----+----------+
| oid | pid | quantity |
+------+-----+----------+
| 1001 | 1 | 2 |
18 rows in set (0.00 sec)
mysql> select * from pvf_product;
+-----+----------------------+----------------+--------+--------------+
| pid | prod_desc | Prod_finish | price | prod_line_id |
+-----+----------------------+----------------+--------+--------------+
| 1 | End Table | Cherry | 175.00 | 1 |
8 rows in set (0.01 sec)
的現在我的查詢變化:
SELECT
pvf_order.cid,
pvf_order.orderdate,
pvf_product.prod_desc,
pvf_order_item.quantity,
pvf_product.price
FROM pvf_order
INNER JOIN pvf_order.oid=pvf_order_item.oid
INNER JOIN pvf_order_item.pid=pvf_product.pid
WHERE YEAR(pvf_order.orderdate)=2014 AND MONTH(pvf_order.orderdate)=10;
我只是不知道到底我要去哪裏錯了。我編輯了一些信息,以避免大量文字,但我希望總體思路在那裏。任何幫助表示讚賞!
你需要有這些變化:'INNER JOIN pvf_order_item ON pvf_order.oid = pvf_order_item.oid'和'INNER JOIN pvf_product ON pvf_order_item.pid = pvf_product.pid' – 1000111
它應該是'INNER JOIN pvf_order_item ON pvf_order .oid = pvf_order_item.oid INNER JOIN pvf_product ON pvf_order_item.pid = pvf_product.pid'您需要提及要連接的表格,而不僅僅是要匹配的字段。 –
真棒謝謝! – Burninrock24