Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to write SQL splicing statements in DELPHI
How to write SQL splicing statements in DELPHI
The key of SQL statement splicing lies in the treatment of quotation marks.

In delphi syntax, single quotation marks are used as identifiers of strings. Therefore, when writing string identifiers in SQL statements, you need to use two single quotation marks instead of the actual quotation marks.

For example:

SQL? :=? Insert? Become? Table (table name)? Value ('? +?' Data value 1'''? +? ' ,'? +? ' ' data value 2''''? +? ','? +? '''' data value''''? +? ')'; It seems that there are too many single quotes, which is quite messy.

In fact, this can be achieved in other ways:

1, using the QuotedStr function.

SQL? :=? Insert? Become? Table (table name)? Value ('? +? QuoteStr ('data value 1')? +?' ,'+? QuotedStr ('data value 2')? +?' ,'+? QuotedStr ('data value 3')? +?' )'; 2. Use the format function

SQL? :=? Format ('insert? Become? Table (table name)? Value (%s, %s, %s)'? [QuoteStr ('data value 1''),? QuotedStr ('data value 2),? QuotedStr ('data value 3')]);