[ic] Way to [query] tall instead of wide?

Peter peter at pajamian.dhs.org
Sun Sep 4 05:26:47 UTC 2011


On 04/09/11 14:16, Paul Jordan wrote:
> 
> Usually you can query select *, grab a bunch of fields, iterate over the
> results found. What if though, I wanted to a bunch of key-value pairs
> from a mess of rows?
> 
> As an example to grasp, let's say that all text on every page was
> editable. You're not going to make tables with a ton of awkward columns,
> you going to produce something like this (key omitted for brevity):
> 
> page_id     area_name      area_value
> 1                title                  My Designer Yoyo's
> 1                heading           Welcome to my......
> 1                email_link        Hit me up!
> 1                step_1_desc    To do step 1, just....
> 1                step 1_title       Do this first!
> (Assume a multi-part uniqueness on page_id+area_name)
> 
> Is there some way to query this and still end up with: [sql-param title]
> [sql-param heading] and so on? The body would not loop of course.

Yep, this is possible.  It shouldn't be difficult to make a usertag to
do this, or to just do it in a straight [perl] block.


Peter



More information about the interchange-users mailing list