簡體   English   中英

如果字符串包含單引號和逗號,如何轉義 Athena INSERT INTO 錯誤?

[英]How to escape Athena INSERT INTO error if string contains single quote and comma?

我必須在 Athena 中插入一條記錄,我在下面使用了 INSERT INTO 查詢,但由於列標題在字符串中包含單引號和 35 之后的逗號而出現錯誤。

insert into database.product (title,description) 
values (
'Waxpol Vinyl & Leather Polish (35', Ltr.)',
'Restores with an extremely High & Durable Shine & Gloss.'
)

錯誤:

在此處輸入圖像描述 僅供參考:桌子是鑲木地板格式

您需要在'Waxpol Vinyl & Leather Polish (35', Ltr.)'中轉義單引號,否則它會變成'Waxpol Vinyl & Leather Polish (35'字符串后跟一些無效的 SQL。您可以使用額外的單引號來做到這一點:

insert into database.product (title,description) 
values (
'Waxpol Vinyl & Leather Polish (35'', Ltr.)',
'Restores with an extremely High & Durable Shine & Gloss.'
)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM