# Print "all column name and content in sql obj"

**URL:** <https://www.ruby-forum.com/t/print-all-column-name-and-content-in-sql-obj/107627>\
**Category:** Rails\
**Created:** [June 24, 2007, 10:37am UTC](https://www.ruby-forum.com/t/print-all-column-name-and-content-in-sql-obj/107627 "2007-06-24T10:37:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 24, 2007, 10:37am UTC](https://www.ruby-forum.com/t/print-all-column-name-and-content-in-sql-obj/107627/1 "2007-06-24T10:37:32Z")

</div>

hi all,

i have a sql obj

(in controller)  
ex: @c = C.find\_by\_sql(“select \* from a,b”)

and i want to print all content in this sql obj c in view .

is there a better way or easy way to print all column name(scheme) in @c  
with a table in

  
and just to print all content in @c with a table in ?

my orginal way :

\<% # may i just print all column name in @c with just a iterator ? %\>

\<% for c in @c %\>

\<% # may i just print all content in @c with just a iterator ? %\>

\<%end%\>

| a | b | c |
| --- | --- | --- |
| c.a | c.b | c.c |

thanks

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 24, 2007, 12:56pm UTC](https://www.ruby-forum.com/t/print-all-column-name-and-content-in-sql-obj/107627/2 "2007-06-24T12:56:47Z")

</div>

\<% for column in {tablename}.content\_columns %\>

\<%= column.human\_name %\>  
\<% end %\>

This is all.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 24, 2007, 1:50pm UTC](https://www.ruby-forum.com/t/print-all-column-name-and-content-in-sql-obj/107627/3 "2007-06-24T13:50:00Z")

</div>

nicolas55ar wrote:

> \<% for column in {tablename}.content\_columns %\>
> 
> \<%= column.human\_name %\>  
> \<% end %\>
> 
> This is all.

thanks, but it works only with “table”,

and i want to take with “query result”,

ex: @c = C.find\_by\_sql(“select \* from a,b”)
