如何将列值转换为行值 [英] How do I convert my column values into row values
本文介绍了如何将列值转换为行值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个表'问题'只有一列'ID'就像这样
ID
image
i have a table 'question' with only one column 'ID' like this"
ID
image
multiple_name
a. CH4+ 2O2 ? CO2 + 2H2O
b. 2CH4+ 2O2 ? 2CO2 + 2H2O
c. 3CH4+ 2O2 ? 2CO2 + 3H2O
d. 2CH4+ 2O2 ? 2CO2 + 4H2O
multiple_correct
yes
hint
i希望这些值存储在另一个表中特定列的行中。
例如:
我的专栏
i want these values to store in rows of specific columns in another table .
for example :
my columns
ID ans1 ans2 ans3
1 a. CH4+ 2O2 ? CO2 + 2H2O b. 2CH4+ 2O2 ? 2CO2 + 2H2O c. 3CH4+ 2O2 ? 2CO2 + 3H2O
继续..
任何人都可以帮助这个吗?
and go on..
can anyone plz help for this??
推荐答案
参考这个..
http://stackoverflow.com/questions/10944910/how-to-convert-a-column-header-and-its-value-into-row-in-sql [ ^ ]
http://stackoverflow.com/questions/7958036/convert-multi-columns-to-rows [ ^ ]
Refer this..
http://stackoverflow.com/questions/10944910/how-to-convert-a-column-header-and-its-value-into-row-in-sql[^]
http://stackoverflow.com/questions/7958036/convert-multi-columns-to-rows[^]
试试这个:
Try this:
select 1 id,
(select * from question where left(id,1)='a') ans1,
(select * from question where left(id,1)='b') ans2,
(select * from question where left(id,1)='c') ans3,
(select * from question where left(id,1)='d') ans4
这篇关于如何将列值转换为行值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文