如何从mysql获取列名 [英] how to get column name from mysql
本文介绍了如何从mysql获取列名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个查询,该查询使用join语句从4个表中检索列.现在我想存储该查询的字段名称的列名或别名.请帮助我如何检索它们?
示例如果我有一个名为A,B,C的表,它们分别具有Aa,Ab,Ac,Ba,Bb,Bc,Ca,Cb之类的列,那么在连接语句I中,我将检索Aa,Bb,Ca,Cb
现在我要保存列名Aa,Bb,Ca,Cb
Hi,
I have query which retrieves columns from 4 tables using join statement.Now I want to store the column name or alias name of the field name of that query.please help me how to retrieve them?
Example If I have table called A,B,C which have columns like Aa,Ab,Ac,Ba,Bb,Bc,Ca,Cb Respectively then in join statement I`l retrieve Aa,Bb,Ca,Cb
Now I want to save Column name Aa,Bb,Ca,Cb
推荐答案
如果您正在执行查询并且结果以DataSet的形式出现,则可以使用DataColumn
获取每个列的名称.
请检查此 [
Hi,
If you are executing your query and your result is in form of DataSet the you can get each column name usingDataColumn
Please check this[^] discussion, you can find your answer from there.
Let me know if you are not storing your query result in DataSet.
Good luck
Thanks
-Amit Gajjar
string [] columnNames = dtGrid.Columns.Cast< datacolumn>().Select(x => x.ColumnName).ToArray();
string[] columnNames = dtGrid.Columns.Cast<datacolumn>().Select(x => x.ColumnName).ToArray();
PLz解释更多,.在查询Plz Explain中签入.
PLz Explain a little More , . Check For into in u query Plz Explain .
这篇关于如何从mysql获取列名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文