Reputation: 21
Please I am new. I am performing an insert select and I want to remove the slashes in a particular field say field b at the select portion of the query. eg. insert into mytable(a,b,c) select a, stripslashes(b),c from mysecondtable;
Please help.
Upvotes: 2
Views: 7370
Reputation: 2258
you can use REPLACE
like this:
insert into mytable(a,b,c)
select a, REPLACE(b, '\\', '\') as b, c
from mysecondtable;
The REPLACE
expression might have to be refined, but I hope this gets you started.
Upvotes: 2
Reputation: 382881
use the SUBSTR function of mysql or do something like this:
"insert into table set value = " . stripslashes('whatever')
Upvotes: 0
Reputation: 188174
You can use MySQL String functions, e.g. replace.
Also consider sanitizing or preparing any input to the SELECT in the calling application before you execute the query.
Upvotes: 0
Reputation: 11208
Are you doint this with PHP? Then a simple $fieldB = strip_slashes($_POST['b']);
should do. You should then use $fieldB
in your query.
Upvotes: -1