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.
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.
Are you doint this with PHP? Then a simple $fieldB = strip_slashes($_POST['b']);
should do. You should then use $fieldB
in your query.
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.
use the SUBSTR function of mysql or do something like this:
"insert into table set value = " . stripslashes('whatever')
Hi Emma, 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.