tags:

views:

231

answers:

4

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.

A: 

Are you doint this with PHP? Then a simple $fieldB = strip_slashes($_POST['b']); should do. You should then use $fieldB in your query.

Ben Fransen
A: 

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.

The MYYN
A: 

use the SUBSTR function of mysql or do something like this:

"insert into table set value = " . stripslashes('whatever')

Sarfraz
+1  A: 

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.

Tom Bartel