Re: need help creating query Nathan G wrote:
>I need help writing a query that returns productIds for products that
> are in the same order as a given productId. (Customers who purchased
> this also bought...)
>
> I have three tables, here they are with their relevant columns.
>
> ORDERS
> oid
>
> ORDERS_CONTENT
> ocid
> oid
> pid
>
> PRODUCTS
> pid
>
> I need to select all pid (product Ids) from orders_content where a
> product Id (we'll use #5 for this example) is in that same order.
>
> So if someone places an order for products #5 and #12, the query would
> return pid 12.
This is not what you described above.
"I need to select ALL pid (product Ids) from orders_content where a
product Id (we'll use #5 for this example) is in that same order."
So I would expect the query to return #5 and #12.
Also, I don't understand how the PRODUCTS table is relevant to this query. |