Re: need help creating query On Jun 9, 2:52*pm, "Paul Lautman" <paul.laut...@btinternet.com> wrote:
> 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.
You are correct, as i stated, it would return 12 and 5. The products
table isnt relevant except to show thats where pid's come from. |