Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to write escape characters in SQL statements?
How to write escape characters in SQL statements?
Two common ways: 1. Escape with brackets []. 2. Use the keyword ESCAPE to escape.

Expand knowledge:

Escape with brackets [].

Example: where column like' AAA[_]BBB '-

Use the keyword ESCAPE to escape.

Example: where column like“% AAA/% BBB%% "escapes"/".

1) Mode 2 is not as convenient as 1, with narrow application and poor definition.

2) Mode 0 is prone to errors when using dynamic SQL, especially in the advanced application of "Nesting+Code Generation".

For example:

Error statement: select * from table _ base where flag _ topic? & amp#{topic_num}。

Error message: causedby: org.xml.sax.saxpasseeexception; Line number: 8; column number:54; The entity name must be immediately followed by'&'in the entity reference.

Correct expression: select * from table _ base where flag _ topic? & ampamp#{topic_num}。