Reputation: 149
In a sql Table , i have a field as Height and i want to insert the height as 5'6'' that is 5 feet and 6 inches. How can i do this?
While using the simple insert command it throws an error. Whats is the possible way to overcome this?
Upvotes: 2
Views: 10237
Reputation: 1
All symbol like ;
, '
, <
, >
, and others must be inserted with backslash before:
\'
\>
\;
In your case:
INSERT INTO tableName (height) VALUES ('5\'\'6\"')
Upvotes: 0
Reputation: 2415
Please try the below
Insert into table_name(column_name) values('5'||''''||'6'||'"');
Upvotes: 0
Reputation: 18569
If you want escape the '
, just put ' twice (''
).
insert into tes values ('5''6''''');
Work in MySQL
, Oracle
and MSSQL
Upvotes: 2
Reputation: 263893
If you are doing it directly on MySQL Server, double the single quote and it will work. Example
INSERT INTO tableName (height) VALUES ('5''6"')
But on front-end, use PreparedStatements for this.
Upvotes: 7