Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Get column name, first record name

Reply
Thread Tools

Get column name, first record name

 
 
Leszek
Guest
Posts: n/a
 
      01-19-2005
Hello!
Can someone help me?

How to get for some records (like 0 or 1) column names?

Example:
I've got a table, that looks

server | parameter1 | parameter2 | parameter3
----------------------------------------------
server1 | 0 | 0 | 1
server2 | 1 | 0 | 1
server3 | 1 | 1 | 0

I want to have all with 0 value:

server | parameter
---------------------
server1 | parameter1
server1 | parameter2
server2 | parameter2
server3 | parameter3

So i need first record from each row and column name for it.
Can someone help me? Please...
I started with .NET in this week...


 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      01-19-2005
It's an sql question. Following select will do.

select server, 'parameter1' as parameter from myTable where parameter1=0
union
select server, 'parameter2' as parameter from myTable where parameter2=0
union
select server, 'parameter3' as parameter from myTable where parameter3=0

Eliyahu

"Leszek" <(E-Mail Removed)> wrote in message
news:OjKsi8f$(E-Mail Removed)...
> Hello!
> Can someone help me?
>
> How to get for some records (like 0 or 1) column names?
>
> Example:
> I've got a table, that looks
>
> server | parameter1 | parameter2 | parameter3
> ----------------------------------------------
> server1 | 0 | 0 | 1
> server2 | 1 | 0 | 1
> server3 | 1 | 1 | 0
>
> I want to have all with 0 value:
>
> server | parameter
> ---------------------
> server1 | parameter1
> server1 | parameter2
> server2 | parameter2
> server3 | parameter3
>
> So i need first record from each row and column name for it.
> Can someone help me? Please...
> I started with .NET in this week...
>
>



 
Reply With Quote
 
 
 
 
Leszek
Guest
Posts: n/a
 
      01-19-2005
Thank you very much!
I thought, tha i must look into row, check each value, get the first record,
column name for this value and put it into a table


Użytkownik "Eliyahu Goldin" <(E-Mail Removed)> napisał w
wiadomości news:efp8GNg$(E-Mail Removed)...
> It's an sql question. Following select will do.
>
> select server, 'parameter1' as parameter from myTable where parameter1=0
> union
> select server, 'parameter2' as parameter from myTable where parameter2=0
> union
> select server, 'parameter3' as parameter from myTable where parameter3=0
>
> Eliyahu
>
> "Leszek" <(E-Mail Removed)> wrote in message
> news:OjKsi8f$(E-Mail Removed)...
>> Hello!
>> Can someone help me?
>>
>> How to get for some records (like 0 or 1) column names?
>>
>> Example:
>> I've got a table, that looks
>>
>> server | parameter1 | parameter2 | parameter3
>> ----------------------------------------------
>> server1 | 0 | 0 | 1
>> server2 | 1 | 0 | 1
>> server3 | 1 | 1 | 0
>>
>> I want to have all with 0 value:
>>
>> server | parameter
>> ---------------------
>> server1 | parameter1
>> server1 | parameter2
>> server2 | parameter2
>> server3 | parameter3
>>
>> So i need first record from each row and column name for it.
>> Can someone help me? Please...
>> I started with .NET in this week...
>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Odd csv column-name truncation with only one column Tim Chase Python 7 07-20-2012 06:09 PM
Why XmlNode.Name get node name and its first attribute together? =?Utf-8?B?ZGF2aWQ=?= ASP .Net 0 03-12-2007 05:06 PM
I'm lazy: how do I make the first databound record not display/chop off the first element from SqlDataSource ASP .Net 7 06-28-2006 10:24 AM
DataGrid loses view state if first column is a template column. Ken Varn ASP .Net 1 08-19-2005 02:54 PM
Re: Urgent! how to get object name, method name and attribute name based on the strings? ding feng C++ 2 06-25-2003 01:18 PM



Advertisments