1

I'm still trying to join tables and it is not running correctly when I try to run it. Also, the bottom block of input it messed up. I want output to display representing values 1-10. Any help will be appreciated.

SELECT customer_id, cust_first_name
FROM demo_customers
WHERE cust_state= 'VA'
INNER JOIN demo_orders
ON demo_customers.customer_id.cust_first_name=demo_orders.order_id


SELECT order_id
FROM demo_orders
WHERE customer_id= '1'

SELECT order_item_id
FROM demo_order_items
WHERE order_id= '2'

SELECT product_name
FROM demo_product_info
WHERE product_id= <10
4

3 回答 3

1
demo_customers.customer_id.cust_first_name = demo_orders.order_id

应该读

demo_customers.customer_id = demo_orders.order_id
于 2013-03-24T18:03:58.573 回答
1

目前尚不完全清楚您在这里追求什么,但这样的事情将提供 4 个表的连接。

SELECT 
   *
FROM 
   demo_customers
INNER JOIN demo_orders
   ON demo_customers.customer_id=demo_orders.customer_id
INNER JOIN demo_order_items
   ON demo_order.order_id = demo_order_items.order_id
INNER JOIN demo_product_info
   ON demo_product_info.product_id = demo_order_item.product_id
WHERE 
  cust_state= 'VA' 
于 2013-03-24T18:34:53.563 回答
1

尝试这个

  SELECT demo_customers.customer_id, demo_customers.cust_first_name
    FROM demo_customers c
      INNER JOIN demo_orders o
    ON demo_customers.customer_id = demo_orders.order_id
       WHERE c.cust_state= 'VA';
于 2013-03-24T18:34:55.960 回答