Re: How to write such a query?

2022-01-06 Thread Dmitry Igrishin
On Thu, Jan 6, 2022, 09:40 Igor Korot wrote: > Hi, ALL, > In SQLite you can write: > > SELECT a, b, c FROM foo WHERE id = :id; > > where ":id" is the named parameter. > > The query above is similar to > > SELECT a,b,c FROM foo WHERE id = ?; > > except that the parameter has a name. > > Is there

Re: How to write such a query?

2022-01-05 Thread Igor Korot
Hi, Armul, On Thu, Jan 6, 2022 at 12:46 AM Amul Sul wrote: > > See prepare statement : > https://www.postgresql.org/docs/current/sql-prepare.html The documentation is talking about a way to do it like: SELECT a, b, c FROM foo WHERE id = $1, which is equivalent to the SELECT a, b, c FROM foo

Re: How to write such a query?

2022-01-05 Thread Ron
On 1/6/22 1:06 AM, Igor Korot wrote: Hi, Ron, On Thu, Jan 6, 2022 at 1:01 AM Ron wrote: On 1/6/22 12:39 AM, Igor Korot wrote: Hi, ALL, In SQLite you can write: SELECT a, b, c FROM foo WHERE id = :id; where ":id" is the named parameter. The query above is similar to SELECT a,b,c FROM foo

Re: How to write such a query?

2022-01-05 Thread Ron
On 1/6/22 1:07 AM, Igor Korot wrote: Hi, David, On Thu, Jan 6, 2022 at 1:00 AM David G. Johnston wrote: On Wednesday, January 5, 2022, Igor Korot wrote: Is there a way to write such a SELECT statement with the named parameter in PostgreSQL? The server, and its prepared SQL capability,

Re: How to write such a query?

2022-01-05 Thread Igor Korot
Hi, David, On Thu, Jan 6, 2022 at 1:00 AM David G. Johnston wrote: > > On Wednesday, January 5, 2022, Igor Korot wrote: >> >> >> Is there a way to write such a SELECT statement with the >> named parameter in PostgreSQL? > > > The server, and its prepared SQL capability, doesn’t understand named

Re: How to write such a query?

2022-01-05 Thread Igor Korot
Hi, Ron, On Thu, Jan 6, 2022 at 1:01 AM Ron wrote: > > On 1/6/22 12:39 AM, Igor Korot wrote: > > Hi, ALL, > > In SQLite you can write: > > > > SELECT a, b, c FROM foo WHERE id = :id; > > > > where ":id" is the named parameter. > > > > The query above is similar to > > > > SELECT a,b,c FROM foo

Re: How to write such a query?

2022-01-05 Thread Ron
On 1/6/22 12:39 AM, Igor Korot wrote: Hi, ALL, In SQLite you can write: SELECT a, b, c FROM foo WHERE id = :id; where ":id" is the named parameter. The query above is similar to SELECT a,b,c FROM foo WHERE id = ?; except that the parameter has a name. Is there a way to write such a SELECT

Re: How to write such a query?

2022-01-05 Thread David G. Johnston
On Wednesday, January 5, 2022, Igor Korot wrote: > > > Is there a way to write such a SELECT statement with the > named parameter in PostgreSQL? > The server, and its prepared SQL capability, doesn’t understand named parameters. Only numbered ones. That said, there are a number of different

Re: How to write such a query?

2022-01-05 Thread Amul Sul
See prepare statement : https://www.postgresql.org/docs/current/sql-prepare.html On Thu, Jan 6, 2022 at 12:10 PM Igor Korot wrote: > > Hi, ALL, > In SQLite you can write: > > SELECT a, b, c FROM foo WHERE id = :id; > > where ":id" is the named parameter. > > The query above is similar to > >

How to write such a query?

2022-01-05 Thread Igor Korot
Hi, ALL, In SQLite you can write: SELECT a, b, c FROM foo WHERE id = :id; where ":id" is the named parameter. The query above is similar to SELECT a,b,c FROM foo WHERE id = ?; except that the parameter has a name. Is there a way to write such a SELECT statement with the named parameter in

Re: How to write such a query

2020-09-19 Thread Francisco Olarte
Igor: > My problem is that I want to emulate Access behavior. > As I said - Access does it without changing the query internally (I presume). > I want to do the same with PostgreSQL. Use access connected to Postgres. > I'm just trying to understand how to make it work for any query > I can have

Re: How to write such a query

2020-09-18 Thread Adrian Klaver
On 9/18/20 1:18 PM, Igor Korot wrote: Hi, Ken, On Fri, Sep 18, 2020 at 2:46 PM Ken Tanzer > wrote: > How to find what the primary key (or UNIQUE identifier) value is > for row 5 in the recordset? You're missing the point: as mentioned

Re: How to write such a query

2020-09-18 Thread Ken Tanzer
On Fri, Sep 18, 2020 at 3:09 PM Igor Korot wrote: > > Now one other little thing: could you point me to the documentation that > explains the meaning of the "window function"? > Can I point you to Google instead? https://www.google.com/search?q=postgresql+window+functions Cheers, Ken --

Re: How to write such a query

2020-09-18 Thread Igor Korot
Ken, On Fri, Sep 18, 2020 at 3:35 PM Ken Tanzer wrote: > On Fri, Sep 18, 2020 at 1:26 PM Ron wrote: > >> On 9/18/20 3:18 PM, Igor Korot wrote: >> > Thank you for the info. >> My problem is that I want to emulate Access behavior. >> >> As I said - Access does it without changing the query

Re: How to write such a query

2020-09-18 Thread David G. Johnston
On Fri, Sep 18, 2020 at 1:18 PM Igor Korot wrote: > As I said - Access does it without changing the query internally (I > presume). > > I want to do the same with PostgreSQL. > I suspect they basically do the equivalent of: UPDATE ... WHERE CURRENT OF ;

Re: How to write such a query

2020-09-18 Thread Ken Tanzer
On Fri, Sep 18, 2020 at 1:26 PM Ron wrote: > On 9/18/20 3:18 PM, Igor Korot wrote: > Thank you for the info. > My problem is that I want to emulate Access behavior. > > As I said - Access does it without changing the query internally (I > presume). > > I want to do the same with PostgreSQL. > >

Re: How to write such a query

2020-09-18 Thread Ron
On 9/18/20 3:18 PM, Igor Korot wrote: Hi, Ken, On Fri, Sep 18, 2020 at 2:46 PM Ken Tanzer > wrote: > How to find what the primary key (or UNIQUE identifier) value is > for row 5 in the recordset? You're missing the point: as mentioned

Re: How to write such a query

2020-09-18 Thread Thomas Kellerer
Igor Korot schrieb am 18.09.2020 um 22:18: Thank you for the info. My problem is that I want to emulate Access behavior. As I said - Access does it without changing the query internally (I presume). I want to do the same with PostgreSQL. I'm just trying to understand how to make it work for

Re: How to write such a query

2020-09-18 Thread Igor Korot
Hi, Ken, On Fri, Sep 18, 2020 at 2:46 PM Ken Tanzer wrote: > > How to find what the primary key (or UNIQUE identifier) value is >> > for row 5 in the recordset? >> >> You're missing the point: as mentioned before, there is no "row 5". To >> update the 5th record that you've fetched, you

Re: How to write such a query

2020-09-18 Thread Rob Sargent
> On Sep 18, 2020, at 1:45 PM, Ken Tanzer wrote: > > > How to find what the primary key (or UNIQUE identifier) value is > > for row 5 in the recordset? > > You're missing the point: as mentioned before, there is no "row 5". To > update the 5th record that you've fetched, you increment a

Re: How to write such a query

2020-09-18 Thread Ken Tanzer
> > > How to find what the primary key (or UNIQUE identifier) value is > > for row 5 in the recordset? > > You're missing the point: as mentioned before, there is no "row 5". To > update the 5th record that you've fetched, you increment a counter each > time > you fetch a row, and when you read

Re: How to write such a query

2020-09-18 Thread Ron
On 9/18/20 1:49 PM, Igor Korot wrote: Hi, Adrian, On Fri, Sep 18, 2020 at 12:58 PM Adrian Klaver wrote: On 9/18/20 10:46 AM, Igor Korot wrote: Hi, Johnathan, On Fri, Sep 18, 2020 at 12:34 PM Jonathan Strong mailto:jonathanrstr...@gmail.com>> wrote: Are you looking to arbitrarily

Re: How to write such a query

2020-09-18 Thread Jonathan Strong
A pretty good read / intro to the concept of keys in the relational model: https://www.red-gate.com/simple-talk/sql/learn-sql-server/primary-key-primer-for-sql-server/ - Jon *Jonathan Strong* CIO / CTO / Consultant

Re: How to write such a query

2020-09-18 Thread Adrian Klaver
On 9/18/20 11:49 AM, Igor Korot wrote: Hi, Adrian, On Fri, Sep 18, 2020 at 12:58 PM Adrian Klaver wrote: On 9/18/20 10:46 AM, Igor Korot wrote: Hi, Johnathan, On Fri, Sep 18, 2020 at 12:34 PM Jonathan Strong mailto:jonathanrstr...@gmail.com>> wrote: Are you looking to arbitrarily

Re: How to write such a query

2020-09-18 Thread Igor Korot
Hi, Adrian, On Fri, Sep 18, 2020 at 12:58 PM Adrian Klaver wrote: > > On 9/18/20 10:46 AM, Igor Korot wrote: > > Hi, Johnathan, > > > > On Fri, Sep 18, 2020 at 12:34 PM Jonathan Strong > > mailto:jonathanrstr...@gmail.com>> wrote: > > > > Are you looking to arbitrarily update the field in

Re: How to write such a query

2020-09-18 Thread Jonathan Strong
Yes...absolutely. Short of using ORDER BY, the order of a multi-row result set can be arbitrary, with "row position" having no significant meaning. This gets back to understanding set theory, the relational model, the various types of keys (primary, candidate, foreign, etc.). Truly crucial to

Re: How to write such a query

2020-09-18 Thread Jonathan Strong
Yes - 100% - Jon *Jonathan Strong* CIO / CTO / Consultant *P:* 609-532-1715 *E:* jonathanrstr...@gmail.com *Quora Top Writer * On Fri, Sep 18, 2020 at 2:22 PM Adrian

Re: How to write such a query

2020-09-18 Thread Adrian Klaver
On 9/18/20 11:13 AM, Jonathan Strong wrote: @Adrian - Using a unique key value or otherwise isolating a specific record via selection against values in its attributes is certainly preferable to choosing a row to update via its position in a result set, unless the use case actually makes use

Re: How to write such a query

2020-09-18 Thread Thomas Kellerer
Igor Korot schrieb am 18.09.2020 um 19:29: [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

Re: How to write such a query

2020-09-18 Thread Jonathan Strong
@Adrian - Using a unique key value or otherwise isolating a specific record via selection against values in its attributes is certainly preferable to choosing a row to update via its position in a result set, unless the use case actually makes use of that position info as a meaningful descriptor

Re: How to write such a query

2020-09-18 Thread Adrian Klaver
On 9/18/20 10:46 AM, Igor Korot wrote: Hi, Johnathan, On Fri, Sep 18, 2020 at 12:34 PM Jonathan Strong mailto:jonathanrstr...@gmail.com>> wrote: Are you looking to arbitrarily update the field in the fifth row, or can the row that needs to be updated be isolated by some add'l

Re: How to write such a query

2020-09-18 Thread Igor Korot
Hi, Johnathan, On Fri, Sep 18, 2020 at 12:34 PM Jonathan Strong wrote: > Are you looking to arbitrarily update the field in the fifth row, or can > the row that needs to be updated be isolated by some add'l attribute? > What's the use case? > What do you mean? I don't have any other

Re: How to write such a query

2020-09-18 Thread Igor Korot
Hi, Paul On Fri, Sep 18, 2020 at 12:34 PM Paul Förster wrote: > > Hi Igor, > > > On 18. Sep, 2020, at 19:29, Igor Korot wrote: > > > > Hi, > > Consider following > > > > [code] > > CREATE TABLE X(id INTEGER PRIMARY KEY, field1 char(50), field2 int); > > CREATE TABLE Y(id INTEGER PRIMARY KEY,

Re: How to write such a query

2020-09-18 Thread Paul Förster
Hi Igor, > On 18. Sep, 2020, at 19:29, Igor Korot 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

Re: How to write such a query

2020-09-18 Thread Jonathan Strong
Are you looking to arbitrarily update the field in the fifth row, or can the row that needs to be updated be isolated by some add'l attribute? What's the use case? - Jon *Jonathan Strong* CIO / CTO / Consultant *P:*

How to write such a query

2020-09-18 Thread Igor Korot
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