Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.databases.postgresql > #825
| From | Dimitri Fontaine <dim@tapoueh.org> |
|---|---|
| Newsgroups | comp.databases.postgresql |
| Subject | Re: lateral query with dynamic column value |
| Date | 2018-05-01 09:50 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <m2po2fzues.fsf@dimitris-macbook-pro.home> (permalink) |
| References | <4c19c4a8-7b74-4890-a349-4fc1c46f91c4@googlegroups.com> |
luca.bocchi8@gmail.com writes:
> I need an help with lateral subqueries:
>
> is it possible to perform it with a dynamically generated column name?
No it is not. SQL is a statically typed language, the SQL engine
(parser, executor) needs to fully determine the data type of the result
of the query before running it.
column_name
> ------------------------------------
> user_id
> warehouse_resume_attribute_user_id
> resume_attribute_000m1_2
> resume_attribute_00032_13
> resume_attribute_00052_13
> resume_attribute_00053_13
> resume_attribute_00057_4
> resume_attribute_00058_7
> resume_attribute_00059_6
> resume_attribute_00061_3
This looks like an EAV data model, which is the worst possible choice on
earth in the relational world. Normalize your data model and then it's
going to be very easy (and efficient) to write your queries.
Regards,
--
Dimitri Fontaine
https://masteringpostgresql.com
Back to comp.databases.postgresql | Previous | Next — Previous in thread | Find similar
lateral query with dynamic column value luca.bocchi8@gmail.com - 2018-04-30 14:03 -0700 Re: lateral query with dynamic column value Dimitri Fontaine <dim@tapoueh.org> - 2018-05-01 09:50 +0200
csiph-web