[thelist] need help selecting dataset from db for use in spreadsheet
Jay Turley
jayturley at gmail.com
Wed Apr 29 13:57:33 CDT 2009
Hi all-
Top of the database day to you! I am currently generating a resultset using
some joins which results in something like this
item_id | item_name | item_attribute | attribute_value
---------------------------------------------------------------------------
1 | A | a1 | v1
1 | A | a2 | v2
2 | B | a1 | v3
2 | B | a2 | v4
3 | C | a1 | v5
3 | C | a2 | v6
This results from a query similar to:
select
i.item_id
,i.name
,ia.item_attribute
,id.attribute_value
from
items i
inner join
item_details id
on
i.item_id = id.item_id
and
id.attribute_value <> '' and id.attribute_value is not null
inner join
item_attributes ia
on
id.attribute_id = ia.attribute_id
and
id.attribute_id in (1, 2)
order by
i.name asc
What I want is to get the data out in a spreadsheet-friendly format:
item_id | name | item_attribute_1 | item_attribute_2
-------------------------------------------------------------------------
1 | A | v1 | v2
2 | B | v3 | v4
3 | C | v5 | v6
I know there's a standard way of approaching this but for the life of me I
can't remember OR find it online. Can one of our database experts give me a
pointer, please?
Thanks a ton!
-Jay
More information about the thelist
mailing list