I'm trying to insert text which happens to contain a sql query into a varchar, but MySQL is producing an error when I execute the insert. How can I accomplish this without producing an error?
Here's what I have so far. I created a table called "info":
CREATE TABLE `info`.`sample` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`one_query` varchar(250) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
And then I try to insert the data:
insert into info.sample (one_query) values ('select u.county_id, u.name from sample.upfall u')
This produces the error message, "You have an error in your SQL syntax; check the manual that... blah blah not very helpful." I think MySQL may be looking at my text as an actual select query, which it's trying to execute.
I think you're using a reserved word. Are there any other fields in your table you're not telling us about?