How to check WHERE clause with apostrophe in a DELETE operation?

Asked

Viewed 155 times

0

I need to delete a record, however, in the WHERE clause one of the data has apostrophe. How can I verify this information, because it is obvious that will give error.

DELETE FROM IES WHERE IDENTIFICACAO ='456' AND ESTADO='SP' AND MUNICIPIO='SAO PAULO' 
AND NOME_IES='UNISANT'ANNA' AND CURSO='PEDAGOGIA' AND TURNO='Noite' AND 
MODALIDADE='Presencial' AND TELEFONE1='1121758000' AND ATENDENTE='2' AND STATUS=0;

Remembering that I tried using quotes and still it was not.

Could you help me?

  • Question: and the table primary key? With it you simply delete the record by Identifier, not all table columns.

  • When you delete vc delete the entire record no matter which filter you used to choose which records will be deleted. Using PK is a good idea when you want to filter records efficiently. If you have a PK list you can use it like this: Where table.colunaPk in (valuePK1,valuePK2,...,valuePKn). Only +1 thing. You do not need to put numerical values between quotation marks.

2 answers

5


If you use two apostrophes ('') should solve it. But I believe that you really should be parameterizing your query, and that character would be no problem.

  • 2

    +1 by indicating the use of parameters

  • In fact, problem solved. Well I wanted to do so, but the system is third party and the coding has been done all this way, the work will be too big to change, in this case, I was forced to follow with the gamb.

0

tries against slash before the bet \'

makes a type of filter in the variable that contains the apostrophe and if you have insert a counter bar before, or checks if it has a function that escapes characters, type htmlspecialchars php

Browser other questions tagged

You are not signed in. Login or sign up in order to post.