I just forgot to add that and activity after that variable.
Details, details, details... :)
The query might be better as a join:
select distinct foo.id key, last_value(data.value) over ( partition by data.foo_id order by data.id ) value from foo, foo_data data where foo.id <> ? and foo.activity is true — and data.foo_id = foo.id and data.aktivity is true and data.key = 'name';
It's just natural derivation after associative arrays and key-value
That is great for programming. In the database world, it is generally considered the wrong approach, when the data is known. If data captured is unknown, it is likely the only choice.
Proper indexing is essential in that key-value-case.
That will work on small tables. Once it gets large, the index is of little help. Partitioned tables is one way out. In any case, EAVs are best avoided.
put everything to db, even code.
People do that, but it is error prone and confusing. Besides, queries can be stored natively in the database as a view or inside a stored procedure. That is what they are there for.
In reply to Re^7: How to interpolate sql-output
by chacham
in thread How to interpolate sql-output
by Seq
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |