Click here to Skip to main content
15,891,976 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I was create a table in sql like 2 COLUMNS CO11 AND CO12

CO11 assign the values of 1 ,0 and 1

CO22 assign the values of 0,1 and 1

i want result in separate column where value is '1' ans will print columns names

What I have tried:

nothing i dont have any idea about that
Posted
Comments
Mehdi Gholam 6-Nov-17 7:27am    
That's not how database tables and queries work.

1 solution

If I've understood what you're asking for, something like this should work:
SQL
SELECT
    'CO11' As ColumnName
FROM
    YourTable
WHERE
    CO11 = 1

UNION ALL

SELECT
    'CO22' As ColumnName
FROM
    YourTable
WHERE
    CO22 = 1

It's difficult to tell from that limited sample, but this does sound like a very bad database design.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900