The variable in a SQL query

Hi.

Im having a problem with a query.

I do a query like so:

<cfquery name="get_databases" datasource="databasename">
  SHOW DATABASES;
</cfquery>
<cfdump var="#get_databases#">

When I do the dump I can see the value for the database name is "DATABASE"
So when I do
<cfloop query="databases">
  <cfoutput>#DATABASE#</cfoutput>
</cfloop>
I get the names of the databases.

My problem is however this:
I want to see the SQL statement to create/copy a table so  I do this:
<cfquery name="show_create" datasource="databasename">
  SHOW CREATE TABLE sometable
</cfquery>      
<cfdump var="#show_create#">
When I do the dump I can see the value for the create table is "CREATE TABLE"
So when I do :
<cfloop query="show_create">
  <cfoutput>#CREATE TABLE#</cfoutput>
</cfloop>
I get an error because there is a space between "CREATE" and "TABLE".

Does anybody know of a different why to get the values of the "show_create" statement I did?

Best regards,  Burkni



LVL 1
Fern2Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hartCommented:
Try this and let me know

<cfquery name="show_create" datasource="databasename">
  SHOW CREATE TABLE sometable
</cfquery>

<cfoutput query="show_create">
  #show_create[currentrow]#
</cfoutput>

Regards
Hart
0
MauseCommented:
Hi

Hart you also need to add ["CREATE TABLE"] to the table in you output

<cfoutput query="show_create">
  #show_create["CREATE TABLE"][currentrow]#
</cfoutput>

Mause
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hartCommented:
Mause : True i missed that out

Regards
Hart
0
Fern2Author Commented:
Thanks guys.

The Mause way worked
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.