1

I have designed java application & mysql database. Textfield also allow to accept whole characters. MySQL database data collation is set to utf8-default & MySQL server version is 5.7. I can type ' character in textfield. But I cannot execute sql syntax with ' in my query.

ex. Name's is not working, but names is working.

MD40
  • 157
  • 2
  • 13
  • Try to insert \' instead or '' – ehh Mar 16 '17 at 07:09
  • obviously, you are creating an insert string. in this case, you have to 'escape' the ' character. you find the answer there: https://dev.mysql.com/doc/refman/5.7/en/string-literals.html – nabuchodonossor Mar 16 '17 at 07:09
  • Thank you all who answered & comment for my question. \' & ''(Additional ' for first one) both are working. – MD40 Mar 16 '17 at 08:01

2 Answers2

0

Make sure you gave same name to your database column name, where you parsing value from the android app.

or

specify your code so we can get more idea.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
0

Try using an extra ' character

If the name is O'Brain , use it as O''Brain

For example

Select * from employees where name like 'O''Brain' 
codeX
  • 4,842
  • 2
  • 31
  • 36