I am saving an SQL query in a database table, so saving the criteria to be used no matter if more records are inputted into the db.
Is there a correct datatype and syntax to use to store the Query statement.
I have set the datatype as VARCHAR(1055) as I think that will be enough.
Is there a MySQL function that will make sure the text is saved correctly
in terms of, quotations and keeping it a single string.
Update: Reason for saving query
We allow the users of the system to create a list of contact details based on other users of the system, so they create the query using a form to select say all users with job type of executive.
The above query is then saved in the database, so that even if a new user is added in the executive job type, his contact details will be included when sending communications.
I think this is the best way to do it...do you have any ideas?
varcharseems like the correct data type to me. It's very unusual to save a query, though. I imagine there's a better way to accomplish whatever it is you're trying to accomplish. It also seems like you're creating additional potential SQL injection points in your application, so you'll want to make sure statements are properly sanitized.