我无法在单引号后使用分号在 PostgreSQL 中创建字符串。 例如。我需要创建一个像这样的字符串:
Delhi is India's capital; It's a beautiful state
如何创建这样的字符串?
我尝试了以下方法:
select 'Delhi is India\'s capital; It\'s a beautiful state'
我收到以下错误:
Invalid operation: unterminated quoted string at or near "'Delhi is India\'s capital"
Position: 8;
最佳答案
在 SQL 中,您不会使用反斜杠转义单引号,而是将它们加倍。分号不需要转义。
所以你应该使用
SELECT 'Delhi is India''s capital; It''s a beautiful state';
关于sql - 如何在 PostgreSQL 字符串中的单引号后添加分号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53887218/