Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Databases _ save a query

Posted by: Mindapolis Apr 11 2012, 08:04 PM

In mysql is there a way to save a query?

Posted by: Frederiek Apr 12 2012, 01:41 AM

What do you mean by "save"? Insert, save to file, export, ...?

Posted by: Mindapolis Apr 12 2012, 08:19 AM

Save, as in you could run the query daily.

Posted by: Brian Chandler Apr 12 2012, 08:23 AM

If the query is 'Q', simply run a program every day (see 'cron') that includes:

mysql_query('Q');

(The answer to your original question is strictly "Yes", because you can make a table with a column 'query' and save queries in it. But it's not clear what use this would actually be.)

Posted by: Mindapolis Apr 12 2012, 09:59 AM

I'm sorry, I'm relatively new to databases. I didn't know you could save queries in a table.

Posted by: Brian Chandler Apr 12 2012, 10:09 AM

QUOTE
I'm sorry, I'm relatively new to databases. I didn't know you could save queries in a table.


Well, you can save strings in a database table, and queries are strings, therefore (provided you escape them properly) you can save queries in DB tables.

Posted by: Darin McGrew Apr 12 2012, 10:59 AM

Or did you mean parameterized statements?

Posted by: Brian Chandler Apr 12 2012, 12:53 PM

QUOTE
Or did you mean parameterized statements?


What difference would it make? Are not parameterized statements represented by strings? (There's the obvious problem of how to pass the parameters, but the question is so up in the air my head is spinning.)

Posted by: Darin McGrew Apr 12 2012, 07:52 PM

I'm just guessing at what the OP might have meant by "save a query"...

Posted by: Frederiek Apr 13 2012, 01:45 AM

QUOTE(Mindapolis @ Apr 12 2012, 04:59 PM) *

I'm sorry, I'm relatively new to databases. I didn't know you could save queries in a table.

Then you should take a look at http://devzone.zend.com/6/php-101--php-for-the-absolute-beginner/ , where there's also a chapter on databases (part 8).

Posted by: Mindapolis Apr 13 2012, 01:49 PM

Thank you so much for the advice

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)