in reply to Perl-MySQL get column names
"What I would like to do is to be able to tag the column name to the value for that column. For example:item1 perl item2 python item3 ruby item4 php"
For mySQL, you can do it in this way:
SELECT concat('item1 ', item1) FROM basket WHERE item LIKE 'a%' UNION SELECT concat('item2 ', item2) FROM basket WHERE item2 LIKE 'a%' ORDER BY 1
For Oracle, I used to do:
SELECT 'item1 ' || item1 FROM basket WHERE item LIKE 'a%' UNION SELECT 'item2 ' || item2 FROM basket WHERE item2 LIKE 'a%' ORDER BY 1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl-MySQL get column names
by Aighearach (Initiate) on Nov 07, 2004 at 20:35 UTC | |
|
Re^2: Perl-MySQL get column names
by kiat (Vicar) on Nov 08, 2004 at 06:27 UTC |