I’m new to sql, trying to insert values in my table
INSERT INTO table1 VALUES (1, ALL||test > test's done> test's done again's done||test > test's done> test's done again's done 2,new);
the second field is of type varchar 4000 charaters.
I’m getting the following error :
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ALL||test > test’s done> test’s done again’s done||test > test’s done> test’s done again’s done 2
Advertisement
Answer
You need to put strings in quotes. And then you need to escape the single quotes. So this looks like:
INSERT INTO table1 VALUES (1, 'ALL||test > test''s done > test''s done again''s done||test > test''s done> test''s done again''s done 2', 'new' );
The double single quotes turns into a single single quote in a string.
Note that you should be listing the column names in the insert, such as:
INSERT INTO table1 (col1, col2, col3) . . .