SQL to Query text in access with an apostrophe in it

后端 未结 5 996
你的背包
你的背包 2020-12-14 00:33

Please help me with this because I cannot seem to get it right

I am trying to query a name(Daniel O\'Neal) in column names tblStudents in an access database however

5条回答
  •  一向
    一向 (楼主)
    2020-12-14 01:22

    You escape ' by doubling it, so:

    Select * from tblStudents where name like 'Daniel O''Neal' 
    

    Note that if you're accepting "Daniel O'Neal" from user input, the broken quotation is a serious security issue. You should always sanitize the string or use parametrized queries.

提交回复
热议问题