Re: How to write such a query - Mailing list pgsql-general

From Igor Korot
Subject Re: How to write such a query
Date
Msg-id CA+FnnTxzWqHBXk5tM8Bvze0hUNAvhg8qPa5PPV3UVs-BkfLQpg@mail.gmail.com
Whole thread Raw
In response to Re: How to write such a query  (Paul Förster <paul.foerster@gmail.com>)
List pgsql-general
Hi, Paul

On Fri, Sep 18, 2020 at 12:34 PM Paul Förster <paul.foerster@gmail.com> wrote:
>
> Hi Igor,
>
> > On 18. Sep, 2020, at 19:29, Igor Korot <ikorot01@gmail.com> wrote:
> >
> > Hi,
> > Consider following
> >
> > [code]
> > CREATE TABLE X(id INTEGER PRIMARY KEY, field1 char(50), field2 int);
> > CREATE TABLE Y(id INTEGER PRIMARY KEY, field1 char, field2 double(10, 2));
> > SELECT X.field1, Y.field2 from X, Y WHERE X.id = Y.id;
> > [/code]
> >
> > Assuming that the SELECT return 10 rows, I want to update X.field1
> > in row 5.
> >
> > How do I write a WHERE clause in the
> >
> > [code]
> > UPDATE X.field1 SET X.field1 = '<some_string>' WHERE....
> > [/code]
> >
> > Thank you.
>
> update x set field1='<some string>' where id=5;

How do you know that the row #5 will have an X.id field 5?

Thank you.

>
> Cheers,
> Paul



pgsql-general by date:

Previous
From: Paul Förster
Date:
Subject: Re: How to write such a query
Next
From: Igor Korot
Date:
Subject: Re: How to write such a query