Re: Help on SQL query

From: Ian Tan <iantan1268(at)gmail(dot)com>
To: Rob Sargent <robjsargent(at)gmail(dot)com>
Cc: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, pgsql-sql(at)lists(dot)postgresql(dot)org
Subject: Re: Help on SQL query
Date: 2019-02-15 18:16:21
Message-ID: CAAj7RQ85Jxa2U3Tya4=2v9cUDN1HQEuGoAsN_Ef7YTcB+tWj4w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello Andrew,
Thank you, I appreciate your response and your help.

Hello Rob,
I learn in my own time and had no one to ask. If pgsql-sql is not the
correct forum for these kinds of question, kindly let me know.

Thank you.

Regards,
Ian

On Fri, 15 Feb 2019 at 17:38, Rob Sargent <robjsargent(at)gmail(dot)com> wrote:
>
>
>
> > On Feb 15, 2019, at 10:28 AM, Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> wrote:
> >
> >>>>>> "Ian" == Ian Tan <iantan1268(at)gmail(dot)com> writes:
> >
> > Ian> How do I write an SQL query so that the "name" text in car_parts
> > Ian> are added to the bill_of_materials table, so that it looks like
> > Ian> this:
> >
> > The only trick with this is that you need to join the car_parts table
> > twice (once for parent and once for child), and to do that you need to
> > give it different alias names:
> >
> > select bom.parent_id,
> > ppart.name as parent_name,
> > bom.child_id,
> > cpart.name as child_name
> > from bill_of_materials bom
> > join car_parts ppart on (ppart.id=bom.parent_id)
> > join car_parts cpart on (cpart.id=bom.child_id);
> >
> > --
> > Andrew (irc:RhodiumToad)
> >
>
> Andrew, will you do my homework too?

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Rob Sargent 2019-02-15 19:03:00 Re: Help on SQL query
Previous Message Rob Sargent 2019-02-15 17:38:08 Re: Help on SQL query